reading a 24Bit word with SX28 and SX/B
$WMc%
Posts: 1,884
Hello all
I'm tring to read a 24Bit word with a SX28.
The word is LSB frist
I have seen this done with a PIC16F876A but it is·in ASM, and I really don't like the PIC Editor, The SX/B is far better in My opion and is in Basic.
I would like to stay with the SX/B and SX28. I'm A newbee to the SX, But I like it.
If Any has some code for this or a link, I would Appt. it.
Thanks in Advance for any help.
______________$WMc%___________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
I'm tring to read a 24Bit word with a SX28.
The word is LSB frist
I have seen this done with a PIC16F876A but it is·in ASM, and I really don't like the PIC Editor, The SX/B is far better in My opion and is in Basic.
I would like to stay with the SX/B and SX28. I'm A newbee to the SX, But I like it.
If Any has some code for this or a link, I would Appt. it.
Thanks in Advance for any help.
______________$WMc%___________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
Comments
BTW, if you have something in PIC Assembly it shouldn't be too difficult to convert to SX/B.
I'm trying to read a postion on a digital caliper ( 0" to 24" )
I have a 4 pin header on the caliper
pin1 = VSS
pin2 = clock clock speed is 77kHz~ This is measured with a Parallax Oscope
pin3 = DATA
pin4 = VDD
The word starts out with a 55uS pause then the 24 bit word and a 55uS stop
I think My real ? is about the 16 bit REG. and a 24bit value.
How do I get the first 16 bits and then catch the last 8 bits in a REG. without them going by the way side.? And how to read this in to differnt REG.?
I'M confused
The Assembly I have converts this 24bit word to Quadrature and involes a lot of hardware.
Anyhelp or links would be great.
I also look forward to Your artc.s in Nut&Volts
____________$WMc%__________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
The trick is shifting a bit from one element to the other -- this is problematic in high-level SX/B because the >> and << operators clear the Carry bit which is what the SX uses to get a bit from one byte to the next. Let's assume the values are arriving MSB-first after the clock line goes high. You might have a loop like this:
If you look at the compiler output for the shift operators you'll see that the Carry gets cleared first (this is why we get a 0 in the LSBit for << or the MSBit for >>). The "shifty" lines above compile to the equivalent of this:
The CLC instruction means CLear Carry. This is why -- with high-level SX/B -- we have to shift and then copy a bit from one element to the other. If we code this "shifty" stuff in Assembly we can use the Carry to our advantage:
As you can see, we copy the Data pin into the Carry bit and the the left shift (RL) instructions move everything through (right to left). Think of the movement of the data bit like this:
calHigh.7 -- calHigh.0 <-- C <-- calLow_MSB.7 -- calLow_MSB.0 <-- C <-- calLow_LSB.7 -- calLow_LSB.0 <-- C <-- DataPin
I don't know if this will help you but, perhaps, it will give you some insight into getting 24 bits from the caliper.
Post Edited (JonnyMac) : 2/9/2009 2:39:27 AM GMT
David
I have tried the ASM code posted. I can see how it works and its very clever. However I keep getting a error from the compiler "Line 68,Error 5,Pass 1:BYTE PARAMETER EXPECTED " idx " "
I'm new to the SXB v3.2.92h BETA and the templates so please for give Me if its something stupid that I have over looked
I don't want to Bugg anybody, But If· You have a minute or two I would App. it a lot.
Thanks in Advance for any help!
__________$WMc%______
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA
Post Edited ($WMc%) : 2/10/2009 1:46:15 AM GMT
Thanks for the reply...Here's the link
http://www.shumatech.com/support/chinese_scales.htm#Chinese Scale Protocol
If above doesn't work Try www.ShumaTech.com
This link shows the protocol, and I have veryfied this with the Parallax Oscope.
*Note this site no longer has the ASM program that converted Chinese to Digimatic or Quadrature, Or the Hardware schematics, But I have these in print. I will try to scan it tomarrow and send it out to this Post.
David Bayliss:Thanks, I knew I was doing something stupid,.........I like to complie/snyntax check code as I go to check for errors.
_____Thanks for the help_____$WMc%_____________
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············································ BoogerWoods, FL. USA