arduino and spi on software(solved)

An area to discuss AVR and Arduino specific problems and examples

Moderator: Benj

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)

Postby ruben_1989 » Thu Apr 02, 2020 6:02 pm

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
(17.02 KiB) Downloaded 24 times
Last edited by ruben_1989 on Thu Apr 09, 2020 2:25 pm, edited 1 time in total.

viktor_au
Posts: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Fri Apr 03, 2020 12:12 am

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

Postby ruben_1989 » Sun Apr 05, 2020 8:32 pm

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 689 times

viktor_au
Posts: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Mon Apr 06, 2020 8:53 am

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.
These users thanked the author viktor_au for the post:
ruben_1989 (Mon Apr 06, 2020 9:14 am)
Rating: 5%
 

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

Postby ruben_1989 » Mon Apr 06, 2020 9:29 am

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: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Mon Apr 06, 2020 10:49 am


viktor_au
Posts: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Mon Apr 06, 2020 11:00 am

Commands
Attachments
digi_pot_commands.jpg
digi_pot_commands.jpg (65.85 KiB) Viewed 661 times
These users thanked the author viktor_au for the post:
ruben_1989 (Mon Apr 06, 2020 12:59 pm)
Rating: 5%
 

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

Postby ruben_1989 » Mon Apr 06, 2020 12:58 pm

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: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Mon Apr 06, 2020 11:49 pm

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

Postby ruben_1989 » Tue Apr 07, 2020 8:20 am

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: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Tue Apr 07, 2020 10:59 am

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

Postby ruben_1989 » Tue Apr 07, 2020 12:17 pm

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 616 times

viktor_au
Posts: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Tue Apr 07, 2020 11:11 pm

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 596 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

Postby ruben_1989 » Wed Apr 08, 2020 9:42 am

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: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Wed Apr 08, 2020 10:39 am

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.
These users thanked the author viktor_au for the post:
ruben_1989 (Thu Apr 09, 2020 6:37 am)
Rating: 5%
 

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

Postby ruben_1989 » Thu Apr 09, 2020 6:37 am

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: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Thu Apr 09, 2020 8:04 am

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.php?title=CAL_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

Postby ruben_1989 » Thu Apr 09, 2020 9:37 am

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.89 KiB) Downloaded 13 times

viktor_au
Posts: 183
Joined: Fri Jan 26, 2018 12:30 pm
Location: South Australia
Has thanked: 33 times
Been thanked: 46 times
Contact:

Re: arduino and spi on software

Postby viktor_au » Thu Apr 09, 2020 10:20 am

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