Announcement

REXYGEN forum has been moved. This one is closed.
Head over to the new REXYGEN Community Forum at https://forum.rexygen.com.

Looking forward to meeting you there!
 

#1 2016-01-30 23:51:58

contactform
Member
Registered: 2015-10-30
Posts: 45

Analog inputs via SPI bus?

Can I take analog inputs to REX, from real world devices via the Rasp pi's SPI bus ?

Thanks!

Offline

#2 2016-01-30 23:57:39

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: Analog inputs via SPI bus?

Hi,
yes you can. Please have a look at our GitHub examples repository, namely the \Integrating_external_devices\SPI folder. The MCP3008 is probably the most popular ADC.

Links to the examples repository can be found here:
https://www.rexcontrols.com/documentation-and-support

Offline

#3 2016-03-25 17:52:15

uxhamby
Member
Registered: 2016-03-25
Posts: 10

Re: Analog inputs via SPI bus?

Sorry Jaroslav but as a new user to RexControls, I am going to need a bit more hand holding here.

For example when I attempt to load mcp3008_exec.mdl into RexDraw, I get an error code 27 dialogue box about file name / module name being different. Is that important or can it be ignored?

Once mcp3008_exec.mdl is loaded by clicking past the error code notification window, I get a blank window with no coding apparent. Is that normal or is that due to the error?

If I load the mcp3008_exec.mdl (again by clicking past the code 27 error) and then call for a rexLang object from the library am I correct in my understanding that "Specify the SPI bus by the fname parameter of the REXLANG function block." means that I should change its fname parameter to "/dev/spi0.0" ?

I am looking forward to seeing this work.

Thanks,

Brian H.

Offline

#4 2016-03-25 18:31:17

tomáš čechura
Administrator
Registered: 2016-02-22
Posts: 371

Re: Analog inputs via SPI bus?

Hello Brian,

hope you wouldn't mind if I will try to answer your questions instead of Jaroslav smile

Please, can you tell me which version of RexDraw do you use at the moment?
I'm also wondering if you haven't renamed the exec or task .mdl file. If so, you can get an error message about the file name because those two file are internally "connected". This error will be fixed in new release, however those two files needs to stay "connected" wink

According to your last question: you are right - you should change Rexlang "fname" parameter to "/dev/spi0.0" (or the correct SPI bus device found in your RPI).

Regards, Tomas

Offline

#5 2016-03-25 22:42:14

uxhamby
Member
Registered: 2016-03-25
Posts: 10

Re: Analog inputs via SPI bus?

Thanks Tomas,

I am running version 2.10.7.5386 of RexDraw on Win XP.

I opened the mcp3008_exec.mdl file just as it came from the GitHub download. When I got the error message I wondered if I was supposed to rename it to just exec.mdl so I created a copy and renamed it but still got the error message. I boggled at that point.

Thanks again,

Brian H.

Offline

#6 2016-03-25 23:16:07

jaroslav_sobota
Administrator
Registered: 2015-10-27
Posts: 535

Re: Analog inputs via SPI bus?

Hello Brian,
thanks for reporting this! Here is the MCP3008 example in a zip file. It is ready to use, no errors or warnings should appear. Open the mcp3008_exec.mdl file, the mcp3008_task should open automatically. Please compare it to the files which you have from GitHub so that we can find the source of the problem. Thanks!

As for the SPI, use the command below to list the available SPI bus.

ls /dev/spi*

In the example I use /dev/spidev0.0 in the fname parameter of the REXLANG function block.

Hope this helps!

Offline

#7 2016-03-26 02:54:09

uxhamby
Member
Registered: 2016-03-25
Posts: 10

Re: Analog inputs via SPI bus?

Thanks Jaroslav, that seems to have helped and I can now see the signals operatin as I vary the voltages to the ADC inputs.

Cheers,

Brian H.

Offline

Board footer

Powered by FluxBB