arduino and spi on software(solved)

An area to discuss AVR and Arduino specific problems and examples

Moderator: Benj

Post Reply
ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

arduino and spi on software(solved)

Post by ruben_1989 »

hi

we are messing around with CAN and SPI the can components works also with SPI and it works with the "hardware" ports . now we would like to use a mcp41010 that also works with SPI . we taught to be smart and use sofware ports and selected some . and we use the uart to figure out Wat went wrong . the program we made worked 2time's and now it doesn't works at al . we used the arduino with out the mcp2515 connected to the arduino
, just measured the clock and cs and mosi for it with the scoop and everythning workes well for the "hardware" part that we use to controle the MCP2515 for the can compnent we see the mosi or data , cs , clock that works fine
If we checked the pins we selected for the spi software component to controle the mcp41010 we only see a cs puls and nothing else no clock no data . nothing . what could be the solution ?

thanks in advantage

kind regard Ruben
Attachments
spi_werkend_pin_via_software_fosc_4.fcfx
(16.92 KiB) Downloaded 232 times
Last edited by ruben_1989 on Thu Apr 09, 2020 2:25 pm, edited 1 time in total.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Hi Ruben
Can you tell please how do you initialise the MCP41010 and set the MCP41010 in potentiometer mode?
And where are the RaiseWiper and LowerWiper macros?
How do you control the MCP41010?
Viktor

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

hi

correct me if I'm wrong . but i don't really initialize the mcp41010 to be a resistor. I just send the adres 17 and
then i send the "waarde" == value of the potentiometer that wil adding up by 1 til 255 and send it with spi macro .
i read in the value of the potentiometer with port AN0 . i tried to explain a bit more trough the print screens.
Hopefully it is a bit more understandable to you what a i do .
Attachments
reading_the_resistant_value.jpg
reading_the_resistant_value.jpg (7.56 KiB) Viewed 10625 times

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Hi again Ruben
Probably I misunderstood you as you used some kind of a different English (without capital letters, without writing I as I and not as i and so on...)
Looks like you have problems with SPI communication but not with the digital potentiometer control.

About initialisation
When you don't init the digital resistor it starts in the middle value.
When you initialise the digital resistor you can set the value at near zero.

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

Hi
Sorry for the misunderstanding. Yes we have a problem with the SPI component when we use the hardware mode everything works fine but if we use the software mode in the properties's of spi macro. There starts the problems sometimes it Will work but most of the time it doesn't work. Is there some kind of command or address I have to use to send to chip to initialize it ?

Ruben

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »


viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Commands
Attachments
digi_pot_commands.jpg
digi_pot_commands.jpg (65.85 KiB) Viewed 10597 times

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

HI
Thanks for the information I know there is an issue if I use another port than the B2 port to control the CS pin with hardware SPI peripheral but this part works really well. Then everything works fine. But when I want to use the software bit banged version, so I can use the hardware part to control the CAN controller. Then it won't work.
I selected software in the red part on the print screen
The commands that I sent you see in the black part on the print screen.
I adjusted them like your advice tot do anything between te cs and the end of it than just sending data on the SPI

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Hi Ruben

Can you please attach the last version of your program?

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

I adjusted something to know what is happening. I have measured with the scoop on the cs line, clock line and the data line. Nothing happens on the clock line and the data line only the cs line gives a pulse for the mcp41010
-clock line = > D5 nothing
-data line => D6 nothing
-CS line => D7 a little pulse

Everything works fine on the SPI of the CAN part. Thank you for your time to find a solution.

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Hello Ruben

You wrote: Everything works fine on the SPI of the CAN part.

I am not sure that I understand.
I checked the SPI Master setting: it is B2 for CS/SS in your program.
However before you send the command and data on SPI you set the D7 to 0 and D7 to 1 after the data is sent.
I think I am missing something.
What is the reason you don't control the CS/SS line by using B2?

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

HI

I use B2 to control the cs line for the SPI connection between the Arduino and mcp2515 can controller.
Attachments
can.jpg
can.jpg (126.46 KiB) Viewed 10552 times

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

ruben_1989 wrote:HI

I use B2 to control the cs line for the SPI connection between the Arduino and mcp2515 can controller.
Please have a look Ruben.
Flowcode does the CS/SS line setting for you as B2.
However in the code the B2 is not controlled.
Attachments
Line CS not controlled-2.jpg
Line CS not controlled-2.jpg (59.69 KiB) Viewed 10532 times

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

I programmed everything like you recommended.still doesn't work
You use the hardware port I use the software (bit banged version) here is where everything goes wrong. Where you selected channel 1 I selected software so I could choose which pins I would use to control SPI
I think there is a bug in flowcode V7 ? :(
I think you use FC V8? Because of the property window is a little different from mine

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Hi Ruben

Questions
1. If you deactivate the UART and CAN-bus, do you have any problems between the arduino and digital pot communication?
2. If you activate the CANbus - will you have any problems?"
3. If you activate the SPI Master, UART and Canbus - will the problem appear?
----------------------------------------------------------------
I am not using CANbus in my projects, but only the Modbus. I cannot check the Can-bus results.
----------
I had a look at B2 port usage in your program.
The B2 port is used by CS/SS line (SPI Master) and the B2 port is used by UART RTS.
Do you see the conflict?
----------
Again, I am not good with Can-bus and I don't know the reason you do use the UART with Can-bus.
When I use the Modbus I don't have to use the UART.
--------
I think you need the help from the advanced users and from Ben as well.
-------
Try to change the UART RTS B2 port to a different one (if you have a free port).
------
About the FC7. Before you jump to a bug reporting let you first check the chip ports and eliminate the conflicts.

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

Hi
first I want to thank you for all of your effort to help me out. I found the solution. I use the macro from SPI master in the sections comms. And this works fine if you work with the hardware ports. Now I use the call spi from the section tools and this made it working :D now I can choose which pins i want to use with the SPI even the CS line that I couldn't select with SPI master from the section commes. Still don't know the real difference between the 2 and wy there on other section but if I use that one all my problems disappear 8) .

grts Ruben

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

I am glad you solved the problem.

PS
By writing that you have used the SPI component from the 'Tools' menu did you want to say
that you have chosen the SPI CAL component?

What is CS/SS line port you have used in SPI CAL component? Is it B2?

A good short info about CAL: https://www.matrixtsl.com/wiki/index.ph ... Components

ruben_1989
Posts: 15
Joined: Wed Feb 19, 2020 11:32 am
Has thanked: 4 times
Been thanked: 2 times
Contact:

Re: arduino and spi on software

Post by ruben_1989 »

Hi

Indeed, SPI CAL component solved everything for me. :D
Thanks for the info !

For the CS/SS line I use B0 now for mcp41010 and B2 for the SPI to communicate with MCP2515
I attached the program that fully works

Thank you for everything.

Ruben
Attachments
SPI_Digital_Pot_SS_software.fcfx
(20.8 KiB) Downloaded 172 times

viktor_au
Posts: 342
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 43 times
Been thanked: 60 times
Contact:

Re: arduino and spi on software

Post by viktor_au »

Good on you Ruben.
The most important thing that you have done everything by yourself.
All the best.

Post Reply