Searching \ for '[SX] reading a 24Bit word with SX28 and SX/B' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/languages.htm?key=sx28
Search entire site for: 'reading a 24Bit word with SX28 and SX/B'.

Exact match. Not showing close matches.
PICList Thread
'[SX] reading a 24Bit word with SX28 and SX/B'
2009\02\07@221255 by WMcKILLemALLn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, WMcKILLemALL wrote:

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%___________
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\07@230506 by JonnyMacn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote:

Read from what?  I use 24-bit values in a camera control program that will be in the March issue of Nuts & Volts; in my case, though, I'm simply incrementing and decrementing a value; I'm not converting to any sort of output
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m326808
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\08@140751 by WMcKILLemALLn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, WMcKILLemALL wrote:

JonnyMac
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%__________
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m326927
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\08@181522 by JonnyMacn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote:

You'll have to synthesize a 24-bit value from a byte and a Word.  Let's say you do this:

calHigh         VAR     Byte                    ' bits 16 - 23
calLow          VAR     Word                    ' bits  0 - 15

The trick is shifting from one to the other -- this is tricky in high-level SX/B because the >> and << operators clear the Carry bit which is what we use 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:

Get_Cal_Bits:
 FOR idx = 0 TO 23
   DO WHILE ClockPin = 0
   LOOP
   calHigh = calHigh << 1
   calHigh.0 = calLow.15
   calLow = calLow << 1
   calLow.0 = DataPin
   DO WHILE ClockPin = 1
   LOOP    
 NEXT

If you look at the compiler output for the shift opeators you'll see that the Carry gets cleared first.  This is why we have to shift and then copy a bit from one element to the other.  In assembly, it's a little easier because the Carry helps us:

Get_Cal_Bits:
 FOR idx = 0 TO 23
   ASM
     JNB   ClockPin, @$
     MOVB  C, DataPin
     RL    calLow_LSB
     RL    calLow_MSB
     RL    calHigh
     JB    ClockPin, @$
   ENDASM
 NEXT

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).  I don't know if this will help you but, perhaps, it will give you some insight into getting 24 bits from the caliper.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327012
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\08@183449 by JonnyMacn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote:

You'll could synthesize a 24-bit value from a byte and a Word. Let's say you do this:

calHigh         VAR     Byte                    ' bits 16 - 23
calLow          VAR     Word                    ' bits  0 - 15

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:

Get_Cal_Bits:
 FOR idx = 0 TO 23
   DO WHILE ClockPin = 0
   LOOP
   calHigh = calHigh << 1
   calHigh.0 = calLow.15
   calLow = calLow << 1
   calLow.0 = DataPin
   DO WHILE ClockPin = 1
   LOOP    
 NEXT

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:

ASM
 CLC
 RL    calHigh
 MOVB  calHigh.0, calLow_MSB.7
 CLC
 RL    calLow_LSB
 RL    calLow_MSB
 MOVB  calLow_LSB.0, DataPin
ENDASM

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:

Get_Cal_Bits:
 FOR idx = 0 TO 23
   ASM
     JNB   ClockPin, @$
     MOVB  C, DataPin
     RL    calLow_LSB
     RL    calLow_MSB
     RL    calHigh
     JB    ClockPin, @$
   ENDASM
 NEXT

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). I don't know if this will help you but, perhaps, it will give you some insight into getting 24 bits from the caliper.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327018
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\09@053817 by dabaylissn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dabayliss wrote:

I haven't tested the code but is it not possible to use an array to avoid the whole carry-shifting problem?



cals VAR Byte(3) ' bits 0-23
CalsIdx var byte
BitsIdx var byte

 
program get_cal_bits
Get_Cal_Bits:
FOR CalsIdx = 0 TO 2
 FOR Bitsidx = 0 TO 7
   DO WHILE ClockPin = 0
   LOOP
   cals(CalsIdx) = cals(CalsIdx) << 1
   cals(CalsIdx).0 = DataPin
   DO WHILE ClockPin = 1
   LOOP
 NEXT
NEXT


David
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327127
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\09@071923 by JonnyMacn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote:

Yep, David, that will work -- but it puts the values into an array which adds its own layer of complexity in SX/B (vis-a-vis treating the bits as one 24-bit value).

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327150
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\09@173938 by WMcKILLemALLn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, WMcKILLemALL wrote:

Hello All
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 " "
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327355
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\09@190005 by dabaylissn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, dabayliss wrote:

The variable IDX needs to be declared before it is used.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327380
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\09@195923 by JonnyMacn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote:

WMc: Do you have link to that caliper and how others were interfacing to it?  The code examples posted above are just for theory explanation; you to know actual clock polarity and the bit order to write a working function.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327393
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\02\10@172548 by WMcKILLemALLn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, WMcKILLemALL wrote:

JonnyMac
Thanks for the reply...Here's the link http://www.shumatech.com/support/chinese_scales.htm#Chinese%20Scale%20Protocol
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%_____________
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=326798#m327679
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...