Question about performing SX comms to A/D thru SPI Microwire
markt
Posts: 2
Hi there,
Please understand that I am new to programming the SX28, but thankfully I have a programming background in Assembly, Java, C, C++.·
I am in the process of developing an application for a weigh scale that will use a CS5531.· This is an analog to digital convertor that has an SPI/Microwire interface through CS, SDI, SDO, SCLK.· I have a great many questions of course.· Some of the main ones are:
1) Is there free source code for performing this type of SPI communications already available?
2) Will I need to add·additional memory to support this kind of functionality?· If so, is there any guides?· I have been looking at the 24LC128
Also, I need to get up to speed ASAP on implementing support for the SX28.· Does anyone have any suggestions as to the sequence of going through the reading materials, tutorials, etc.?·
Any help/suggestions would be very much appreciated.
Thank you,
Mark.
Please understand that I am new to programming the SX28, but thankfully I have a programming background in Assembly, Java, C, C++.·
I am in the process of developing an application for a weigh scale that will use a CS5531.· This is an analog to digital convertor that has an SPI/Microwire interface through CS, SDI, SDO, SCLK.· I have a great many questions of course.· Some of the main ones are:
1) Is there free source code for performing this type of SPI communications already available?
2) Will I need to add·additional memory to support this kind of functionality?· If so, is there any guides?· I have been looking at the 24LC128
Also, I need to get up to speed ASAP on implementing support for the SX28.· Does anyone have any suggestions as to the sequence of going through the reading materials, tutorials, etc.?·
Any help/suggestions would be very much appreciated.
Thank you,
Mark.
Comments
Ken
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
"If you keep doing what you always did, you'll keep getting what you always got."
·
A question regarding the SHIFTOUT SX/B command; I found a Basic Stamp program that communicates with a Cirrus CS5531 which is exactly what I need but for SX28 so I need to convert. The SHIFTOUT command seems to be "expanded" with the Basic Stamp compiler and allows the programmer to concatenate a series of bits plus multiple bytes of data in a very flexible manner, whereas SX/B SHIFTOUT command allows a maximum of 8 bits in a single command statement. My question is, how can I get around this limitation? Do I use an array of bytes together with a loop to call the SHIFTOUT command multiple times, using the loop index counter to pass all the bytes of the array? Or, is this going to get me into trouble? The SPI code support for the SC5531 requires >32 bits of data passed with each SHIFTIN/SHIFOUT. If I use mutliple instances of SHIFTIN/OUT I will burn up all my memory. Other thoughts I was playing with was to look at the assembly created and try modifying to expand number of bits (could be time consuming). Also, maybe a subroutine passing the data to and from a SHIFOUT and SHIFTIN sub. Here is a code sample that I was playing around with:
idx var byte 'loop counter
dathi var byte(2) '16 bit high address
datlo var byte(2) '16 bit low address
...
for idx = 0 to 1
shiftin SDO,SCLK,0,dathi(idx)
next
...
Any help would be much appreciated.
Thanks again,
Mark T.
The key to not "burning up all you memory" is to put SX/B commands into subroutines -- the same way assembly programmers do. If you were coding in pure assembly you wouldn't duplicate code for shifting bits out an SPI port, so don't so it in SX/B. The SX/B help file does have SPI examples that you can learn from. Take your time and build your project slowly -- if you try to rush through it you'll end up creating more problems than solving.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
About two years ago I did a project making a rather compicated strain gage weighing system using multiple remotely located CS5525, each with its own SX, all communicating RS485 back to one central where the controls and display were loctaed. It was very complicated and a LOT of work (those chips are not all that friendly and several poorly documented traps), but once I got it done, they have been operating reliably in the field. We were able to reliably measure one gram in 30 Kilograms.
As this relates to industrial measurement and control systems, (the business I'm in), I would only be interested in selling my design and software at commercial rates. I'm POSITIVE I will save you a TON of time, hence presumably a ton of money.
Cheers,
Peter (pjv)