Page 1 of 1

arduino and spi on software(solved)

Posted: Thu Apr 02, 2020 6:02 pm
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

Re: arduino and spi on software

Posted: Fri Apr 03, 2020 12:12 am
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

Re: arduino and spi on software

Posted: Sun Apr 05, 2020 8:32 pm
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 .

Re: arduino and spi on software

Posted: Mon Apr 06, 2020 8:53 am
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.

Re: arduino and spi on software

Posted: Mon Apr 06, 2020 9:29 am
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

Re: arduino and spi on software

Posted: Mon Apr 06, 2020 10:49 am
by viktor_au

Re: arduino and spi on software

Posted: Mon Apr 06, 2020 11:00 am
by viktor_au
Commands

Re: arduino and spi on software

Posted: Mon Apr 06, 2020 12:58 pm
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

Re: arduino and spi on software

Posted: Mon Apr 06, 2020 11:49 pm
by viktor_au
Hi Ruben

Can you please attach the last version of your program?

Re: arduino and spi on software

Posted: Tue Apr 07, 2020 8:20 am
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.

Re: arduino and spi on software

Posted: Tue Apr 07, 2020 10:59 am
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?

Re: arduino and spi on software

Posted: Tue Apr 07, 2020 12:17 pm
by ruben_1989
HI

I use B2 to control the cs line for the SPI connection between the Arduino and mcp2515 can controller.

Re: arduino and spi on software

Posted: Tue Apr 07, 2020 11:11 pm
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.

Re: arduino and spi on software

Posted: Wed Apr 08, 2020 9:42 am
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

Re: arduino and spi on software

Posted: Wed Apr 08, 2020 10:39 am
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.

Re: arduino and spi on software

Posted: Thu Apr 09, 2020 6:37 am
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

Re: arduino and spi on software

Posted: Thu Apr 09, 2020 8:04 am
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

Re: arduino and spi on software

Posted: Thu Apr 09, 2020 9:37 am
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

Re: arduino and spi on software

Posted: Thu Apr 09, 2020 10:20 am
by viktor_au
Good on you Ruben.
The most important thing that you have done everything by yourself.
All the best.