Searching \ for '[SX] Bean's SX28 8x8 PWM Code and SX28 Addressable' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/ubicom/lib/io/index.htm?key=pwm%2Finde+pwm
Search entire site for: 'Bean's SX28 8x8 PWM Code and SX28 Addressable'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Bean's SX28 8x8 PWM Code and SX28 Addressable'
2008\02\29@172419 by DigitalDjn/a

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

Hey Gang!

I would like to see if it's possible to make Bean's SX28 8x8 PWM code so this it makes the SX28 addressable. I would like to use more than one processor for more outputs, actually at least 3 SX28's one for red, green and blue.


I didn't post the code without getting Beans ok! Bean is it ok to post your code?


Thanks,
Kevin



 

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

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


'[SX] Bean's SX28 8x8 PWM Code and SX28 Addressable'
2008\03\01@095505 by beann/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, bean wrote:

Yeah sure you can post it.

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

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

2008\03\01@200043 by DigitalDjn/a

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

This is the code of Bean's that I need to add in a way to make it addressable. I guess I could probably do it a couple of ways but I wanted to get some input on the best way. For 1 I could put it right in with the !PWM to control the outputs or use some pins on the SX and when the pins are low I could set them as 1, 2 and 3. I'm not real sure on how to pull this off on the pin configuration and the code.

I would appreciate any ideas and help!

Thanks,
Kevin


' =========================================================================
'
'   File...... PWM64.SXB
'   Compiler.. SX/B Version 1.22
'   Purpose... 64 Multiplexed Channels of PWM (For LED matrix control)
'   Author.... Hitt Consulting
'   E-mail.... terry@hittconsulting.com
'   Started... June 15, 2005
'   Updated...
'
' =========================================================================
' -------------------------------------------------------------------------
' Program Description
' -------------------------------------------------------------------------
' Accepts serial data at 9600 baud and provides 64 channels of duty cycle modulated PWM
' Serial data is sent with a header of "!PWM" then 64 bytes of data (0=full off, 255=full on)
'
' OSC1&2 = 50Mhz resonator
' Port RA.3 = Serial input
' Port RB = Rows 0 to 7 (Active High)
' Port RC = Column 0 to 7 (Active High, use NPN transistor as column driver)
'
'         10K
' /MCLR -/\/\/\----- Vdd Pin
'
'         10K
' RA.3 -/\/\/\-----< Serial Input (9600 baud 8N1 Inverted)
'
'      220 Ohm
' RB.0 -/\/\/\-----> PWM Output Row 0
'
'      220 Ohm
' RB.1 -/\/\/\-----> PWM Output Row 1
'
'      220 Ohm
' RB.2 -/\/\/\-----> PWM Output Row 2
'
'      220 Ohm
' RB.3 -/\/\/\-----> PWM Output Row 3
'
'      220 Ohm
' RB.4 -/\/\/\-----> PWM Output Row 4
'
'      220 Ohm
' RB.5 -/\/\/\-----> PWM Output Row 5
'
'      220 Ohm
' RB.6 -/\/\/\-----> PWM Output Row 6
'
'      220 Ohm
' RB.7 -/\/\/\-----> PWM Output Row 7
'
'      1K Ohm
' RC.0 -/\/\/\-----> Column Output 0 (To base of NPN column driver)
'
'      1K Ohm
' RC.1 -/\/\/\-----> Column Output 1 (To base of NPN column driver)
'
'      1K Ohm
' RC.2 -/\/\/\-----> Column Output 2 (To base of NPN column driver)
'
'      1K Ohm
' RC.3 -/\/\/\-----> Column Output 3 (To base of NPN column driver)
'
'      1K Ohm
' RC.4 -/\/\/\-----> Column Output 4 (To base of NPN column driver)
'
'      1K Ohm
' RC.5 -/\/\/\-----> Column Output 5 (To base of NPN column driver)
'
'      1K Ohm
' RC.6 -/\/\/\-----> Column Output 6 (To base of NPN column driver)
'
'      1K Ohm
' RC.7 -/\/\/\-----> Column Output 7 (To base of NPN column driver)
' -------------------------------------------------------------------------
' Device Settings
' -------------------------------------------------------------------------
DEVICE          SX28, OSCHS2, TURBO, STACKX, OPTIONX, BOR42
FREQ            50_000_000
' -------------------------------------------------------------------------
' IO Pins
' -------------------------------------------------------------------------
SerialInPin VAR RA.3
' -------------------------------------------------------------------------
' Constants
' -------------------------------------------------------------------------
Baud  CON "N11034" ' Adjusted baud rate for 9600 baud incoming 9600/0.870
   '  This adjustment is need because the interrupt uses
   '  130 cycles every 1000 clocks. So the main code only
                               '  gets 870 cycles of every 1000 clocks.  
' -------------------------------------------------------------------------
' Variables
' -------------------------------------------------------------------------
' Variables for PWM Interrupt
Column  VAR BYTE ' 1,2,4,8,16,32,64,128
DataPlace VAR BYTE ' Pointer to PWM values
PWM_Count VAR BYTE
PWM_Values0 VAR BYTE (8)
PWM_Values1 VAR BYTE (8)
PWM_Values2 VAR BYTE (8)
PWM_Values3 VAR BYTE (8)
PWM_Values4 VAR BYTE (8)
PWM_Values5 VAR BYTE (8)
PWM_Values6 VAR BYTE (8)
PWM_Values7 VAR BYTE (8)
' Variables for main code
Count  VAR BYTE
SerialData VAR BYTE ' Set by subroutine "GetSerialChar"
' -------------------------------------------------------------------------
INTERRUPT
' -------------------------------------------------------------------------
ISR_Start:
' Entry and Exit code (37) cycles
' (93+37=130) cycles. NOTE: each path through the interrupt routine should be the
' same number of cycles, so the SERIN command works properly.
ASM
INC PWM_Count  ' (1) Adjust the PWM count
   '     If the PWM value for each channel is less than
   '     PWM_Count then it should be high, othewise it
   '     should be low.
JZ :AdjustColumn ' (2/4)
NOP   ' (1)
JMP $+1   ' (3)
JMP $+1   ' (3)
JMP $+1   ' (3)
JMP :ColumnOk  ' (3)
:AdjustColumn
ADD DataPlace,#$08 ' (2)
RL Column  ' (1)
JC :ResetColumn  ' (2/4)
MOV W,#$10  ' (1)
       SB DataPlace.4  ' (1/2)
ADD DataPlace,W  ' (1)
JMP :ColumnOk  ' (3)
:ResetColumn
MOV Column,#1  ' (2)
MOV DataPlace,#PWM_Values0 ' (2)
:ColumnOk
MOV RC,Column  ' (2)
MOV __PARAM4,PWM_Count ' (2) Make copy of PWM_Count in global memory
MOV FSR,DataPlace ' (2) Set FSR to address of 1st element of PWM values
CJA IND,__PARAM4,:HIGH_B0 ' (4/6)
CLRB RB.0 ' (1)
JMP :DONE_B0 ' (3)
:HIGH_B0
SETB RB.0 ' (1)
NOP  ' (1)
:DONE_B0
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B1 ' (4/6)
CLRB RB.1 ' (1)
JMP :DONE_B1 ' (3)
:HIGH_B1
SETB RB.1 ' (1)
NOP  ' (1)
:DONE_B1
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B2 ' (4/6)
CLRB RB.2 ' (1)
JMP :DONE_B2 ' (3)
:HIGH_B2
SETB RB.2 ' (1)
NOP  ' (1)
:DONE_B2
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B3 ' (4/6)
CLRB RB.3 ' (1)
JMP :DONE_B3 ' (3)
:HIGH_B3
SETB RB.3 ' (1)
NOP  ' (1)
:DONE_B3
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B4 ' (4/6)
CLRB RB.4 ' (1)
JMP :DONE_B4 ' (3)
:HIGH_B4
SETB RB.4 ' (1)
NOP  ' (1)
:DONE_B4
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B5 ' (4/6)
CLRB RB.5 ' (1)
JMP :DONE_B5 ' (3)
:HIGH_B5
SETB RB.5 ' (1)
NOP  ' (1)
:DONE_B5
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B6 ' (4/6)
CLRB RB.6 ' (1)
JMP :DONE_B6 ' (3)
:HIGH_B6
SETB RB.6 ' (1)
NOP  ' (1)
:DONE_B6
INC FSR  ' (1)
CJA IND,__PARAM4,:HIGH_B7 ' (4/6)
CLRB RB.7 ' (1)
JMP :DONE_B7 ' (3)
:HIGH_B7
SETB RB.7 ' (1)
NOP  ' (1)
:DONE_B7

ENDASM  
ISR_Exit:
 RETURNINT 250 ' Prescaler at 1:4 = 1000 cycles or 20uSec = 256*20uSec=5.12mSec or 195 Hz
' =========================================================================
PROGRAM Start ' Allow startup code to zero PWM values
' =========================================================================
' -------------------------------------------------------------------------
' Subroutine Declarations
' -------------------------------------------------------------------------
GetSerialChar SUB 0
' -------------------------------------------------------------------------
' Program Code
' -------------------------------------------------------------------------
Start:
 TRIS_B=%00000000 ' All outputs
 TRIS_C=%00000000 ' All outputs
 ' Setup so at next interrupt will restart at column 0
 PWM_Count = 255
 DataPlace = PWM_Values7
 Column = 128  
 ' Enable RTCC interrupt
 OPTION=$81 ' Enable RTCC interrupts, RTCC Prescaler = 1:4
Main:
 ' Wait for "!PWM" header
 GetSerialChar
 IF SerialData <> "!" THEN Main
 GetSerialChar
 IF SerialData <> "P" THEN Main
 GetSerialChar
 IF SerialData <> "W" THEN Main
 GetSerialChar
 IF SerialData <> "M" THEN Main
 ' Get Data for 64 PWM channels
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values0(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values1(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values2(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values3(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values4(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values5(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values6(Count)=SerialData
 NEXT
 FOR Count=0 TO 7
   GetSerialChar
   PWM_Values7(Count)=SerialData
 NEXT
 ' Do it again
 GOTO Main
' -------------------------------------------------------------------------
' Subroutine Code
' -------------------------------------------------------------------------
GetSerialChar:
 SERIN SerialInPin,Baud,SerialData
RETURN

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

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

2008\03\02@190642 by Zootn/a

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

Just add something like this in where the mainline program checks for the received serial header:


 GetSerialChar
 IF SerialData <> "M" THEN Main
' after the above, check for "unique" address -- with a byte you would get up to 256 addressable chips on one serial line:
 GetSerialChar
 IF SerialData <> $01 THEN Main ' this would only allow this chip to respond to address 0x01

The bigger question to decide is if you want each SX to be hardware addressable or have the address encoded permanantly in firmware. The former would require that you use some pins along with jumpers/dip switch to "read" a hardware address. The latter is more flexible and takes no pins, but you would have to download a slightly different version of the firmware to each chip (the only difference in each version would be the address).

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

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

2008\03\02@191123 by Zootn/a

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

P.S. -- since it looks like three pins are free, you could have up to 8 chips on one serial line using pin hardware addressing. Set up jumpers or dipswitch to the 3 pins and have the SX check those pins for it's "address" on reset, e.g.:


myAddress VAR Byte
Start:

 myAddress = RA & %0111  ' read 3 RA pins and mask off pin 3 (serial) for resulting address, 0-7
Main:

 ' get and check for !PWM header, then...
 GetSerialChar
 IF SerialData <> myAddress ' address match? no, try again


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

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

2008\03\02@192145 by DigitalDjn/a

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

Zoot,

Thanks for the response!


Any ideas as how to do this by hardware, let's say I want to use dip switches. I guess the other idea is could it be setup as board 1,2,3 etc and then each board chip have it's own address. If I had any number of boards the chips on each board could have the same address but the main address would be the board 1,2,3. Maybe this isn't possible unless I was using serial comunications from a main(master) sx28 to the other 3 pwm sx's on the board. I plan on just the 3 sx's for now and if i was to make the board stand alone it would then require a master sx.


Regards,
Kevin
---------- End of Message ----------

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

2008\03\03@070758 by Zootn/a

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

No, your limit per serial wire depends on how you approach it. If you "hardcode" the address into the firmware, you could have up to 256 addresses (chips) on the one wire (presuming a byte as the address).

If you want a dip-switch/jumper hardware address (so that firmware is same for all chips) then I think you would be limited to 8 chips on one wire, since you only have 3 pins avail. for addressing.

For the latter, all you would need to do is wire dip-switches (or jumpers/headers) to RA.0...RA.2 so that the switch/jumper selection sends a 5v high or 0v low to the pin. On reset, the firmware reads the state of the 3 address pins to see what it's own address is, then saves that info in a variable (actually, you don't even need the variable -- you could just read the 3 pins every time you need to check the address).

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

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

2008\03\03@092047 by lordsteven/a

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

Alternatively, you could use a demultiplexer that will take the address of the SX you want to talk to and output a chip-select-like signal to the appropriate SX.  This would use only one of the three spare pins on your SXs.  There exist 8-to-1 and 16-to-1 demuxes.  The SX28 can be used as a 16-to-1 demux with a simple demultiplexer virtual peripheral.

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

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

2008\03\03@193744 by DigitalDjn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, DigitalDj wrote:

Thanks Zoot I will give these ideas a try!

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

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

2008\03\05@181258 by DigitalDjn/a

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

OK I am using a RS232 program for communicating with the SX28 via the serial port but I am unsure what format I should be sending the !PWM, 255, 255 etc. in, can some one tell me what format this is. I did some reading and I know or think I know that is not hex, binary or ascii.

HELP!

Thanks,
Kevin
---------- End of Message ----------

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

2008\03\05@185511 by PJMontyn/a

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

Kevin,
!PWM is plain old ASCII.

The remaining data is sent as raw binary values.  You need to send 64 bytes of data, one for each LED.  
Thanks,
PeterM
---------- End of Message ----------

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

2008\03\05@190431 by DigitalDjn/a

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

Can you show me an example?

I guess the problem I am having is how to send mixed data.

Thanks,
kevin
---------- End of Message ----------

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

2008\03\06@001250 by HenrikKempen/a

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

You simply send the command '!PWM' followed by 64 bytes with the value of 255, not the separate 2 5 5s.

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

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

2008\03\06@140855 by PJMontyn/a

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

Terminal emulator typically stink at sending raw, binary data.  One exception is the free (and open source) RealTerm.  Here's the SourceForge link:

http://realterm.sourceforge.net/
You can type a series of numbers and it can send them as either ASCII or numbers.  I was most recently using it for testing an LCD backpack I was working with.  The backpack used values below 32 as control characters.  It was super easy to use RealTerm to send the control number as numbers and thensend the printable text as ASCII.

Thanks,
PeterM
---------- End of Message ----------

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

2008\03\06@170815 by DigitalDjn/a

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

PJmonty,
Thanks, I will give that a try. I did find out that it needs to be sent in ascii but the values have to be sent in the equivelant ascii characters.

With your suggested terminal program sounds like it solves the difference.

I had to order a resonator for the 16pwm code and I am waiting on trying that, though I may just go ahead and try the code listed above, I have a resonator for it.

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

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

2008\03\07@091852 by PJMontyn/a

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

Kevin,
You said, "I did find out that it needs to be sent in ascii but the values have to be sent in the equivalent ascii characters."  I think you may need a little more clarity on this issue.

Actually, it doesn't "need" to be sent in ASCII.  The fact that you're sending the ASCII equivalent values means you're sending raw binary but using the mechanism of ASCII equivalent characters to send them via a terminal program.  If you wrote your own program on the PC to talk to the PWM board, you'd just be sending binary values.  You wouldn't bother doing some conversion from binary to ASCII as you could just send binary.  
The only reason ASCII enters the equation is that you're using a terminal emulator and not a custom program.  As I mentioned in the previous post, terminal emulators typically stink at sending binary data.  RealTerm is the only one I have seen that is any good at sending binary at all, although I'm sure there are others.

Good luck with the project.

Thanks,
PeterM
---------- End of Message ----------

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

2008\03\07@103933 by DigitalDjn/a

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

I see what you talking about with the terminal program! As soon as I get my resonator and get some stuff off of my SX Tech board that I have been playing with I will try the 16pwm code first then the pwm8x8 code. I downloaded Realterm to try if my rs232 program won't work. I will probably write some VB6 code to control these once I know what I am doing on the serial info. I have some serial code already that I have used in some other code. Typically I have dealt with sending hex and not ascii or binary.

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

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

2008\03\07@120249 by PJMontyn/a

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

Kevin,
Hex is binary is decimal.  Huh?  In other words, all three of those are simply different ways of expressing a number using a different base.  Hex is base 16, binary is base 2, and decimal is base 10.  All of that is simply stuff we humans use to make things easier to read/write/understand.

When I say  "sending binary data", I'm simply referring to sending 8 bits where the value of the eight bits equals the numerical value you want to send.  For example, if you want to send the number 123 to your pwm board, you don't send the string "123", you send the 8 bits of data that represent the number 123.  
In binary, 123 = 01111011
In hex, 123 = $7B
You mention sending hex in a VB program.  The question is are you sending a hex string or a hex value?  If it's a hex string, then when you want to send 255 you send the actual character "$"  followed by "F" and followed by another "F".  This would be sending the hex string "$FF".  that's three bytes of data to send a single value.  In addition, whatever receives that string has to decode the string an figure out what number it represents.  Conversely, if you sent a hex value, you would send just one byte of data, and all eight data bits coming out of the UART have a value of 1.  The device receiving it doesn't have to decode that value because it is the number 255, not a string representation of it.

I hoe this makes sense.  It sounds like you might still be hazy on the difference between sending a string and sending a number, regardless of what base it is in.  I just want to make sure it's clear before you drive yourself crazy.  See the recent thread on this forum about the serial inkjet printer to see what kind of frustration you can have if you're not clear about this issue.

Thanks,
PeterM
---------- End of Message ----------

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

2008\03\16@164113 by DigitalDjn/a

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

PJ,
Sorry I didn't get a email that there was a reply to the thread. Thanks for explaining and yes i'm a little hazy on the serial stuff. I now know to send a string it is $FF for 255 and requires 3 bytes which is what I don't want to do, correct? Since I can send ASCII to the board then I can truly send !PWM, 255, 255, 255 etc. correct?

I attached the code from the VB6 example that I modified from Al Williams code for his example to use with his PakV SX28 chip.

I just basically have the serial code setup so when the sliders are changed it automatically sends un update to the SX. Everything that is commented is just the old code. I haven't ried this as I am waiting on a 20mhz resonator.


'Dim SX28Cmd(15) As Integer
 
Private Sub Adjust_Change(Index As Integer)
SetVolt Index
End Sub
 
Private Sub SetVolt(Index As Integer)
'Dim cmd As Integer
Dim duty As Integer
Dim voltage As Single
'cmd = SX28Cmd(Index)
'duty = -Adjust(Index).Value

'voltage = 5# * duty / 256#
 
Dim o$ 'will hold 16 consecutive value bytes
Dim i%
 
For i = 0 To 15
 duty = -Adjust(i).Value
 voltage = 5# * duty / 256#
 o$ = o$ + Chr$(duty)
 Volt(i) = Format(voltage, "0.0")
Next
If MSComm1.PortOpen = True Then
 MSComm1.Output = "!PWM" + o$
'Else
  'Beep
End If
'Volt(Index) = Format(voltage, "0.0")
End Sub

Private Sub Adjust_Scroll(Index As Integer)
SetVolt Index
End Sub
 
Private Sub CloseBtn_Click()
End
End Sub
 
Private Sub Combo1_Change()
BreakConnect
MSComm1.CommPort = Combo1.ItemData(Combo1.Index)
End Sub
 
Private Sub MakeConnect()
  Dim i As Integer
  On Error Resume Next
  MSComm1.PortOpen = True
  Connect.Caption = "&Disconnect"
  MSComm1.Output = Chr(&H85)
  For i = 0 To 15
    SetVolt (i)
  Next
End Sub
 
Private Sub BreakConnect()
  On Error Resume Next
  MSComm1.PortOpen = False
  Connect.Caption = "Co&nnect"
End Sub
 
Private Sub Combo1_Click()
 BreakConnect
 MSComm1.CommPort = Combo1.ItemData(Combo1.ListIndex)
End Sub
 
Private Sub Command1_Click()
 Debug.Print MSComm1.CommPort; ", "; MSComm1.Settings
End Sub
 
Private Sub Connect_Click()
If Connect.Caption = "Co&nnect" Then
  MakeConnect
Else
  BreakConnect
End If
End Sub
 
Private Sub Form_Load()
'Dim i As Integer
'Dim v As Integer
'v = &H21
'For i = 0 To 15
 'SX28Cmd(i) = v
 'v = v + 2
'Next
End Sub

Thanks,
Kevin
---------- End of Message ----------

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

2008\03\17@175215 by PJMontyn/a

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

Kevin,
You said, "I now know to send a string it is $FF for 255 and requires 3 bytes which is what I don't want to do, correct?"
Yes and no.  Yes, you don't want to do this.  No, $FF is not always a string for 255.  In fact, it's not a string at all since it's not in quotes.  Anything in quotes in a string.  Here's a string:

"Kevin"
Here's another:

"$FF"
And here's a third:

"255"
If I write 255 and don't surround it with quotes, the VB compiler won't recognize it as a string.

$FF is just the hexadecimal version of 255 which is the decimal version of the binary 11111111.

Your program does send the correct values, but it seems you may yet not be clear on why.  You have the line:

o$ = o$ + Chr$(duty)

This line is taking the string variable called os$ and filling it with binary values by using the chr$ command.  Here's a webpage that helps explain strings and the chr$ command:

http://www.vbexplorer.com/VBExplorer/focus/strings_tutorial.asp
Thanks,
PeterM
---------- End of Message ----------

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

2008\03\24@013347 by David Cary

face picon face
> your limit per serial wire depends on how you approach it.

That's certainly true.
But I am mystified as to why so many people "hardcode" addresses into
firmware -- that requires a custom version of the code for every chip
on the serial network.
I am also mystified as to why so many people "use a dip switch", which
requires a bunch of pins to read the dip switch.

Why don't these people use "scalable" networking protocols that scale
up to an unlimited number of chips?
Protocols that work fine with identical firmware in every chip, and
only require a maximum of the "serial data in" pin plus 2 or so other
pins on the master and each slave, even if there are dozens of slaves?

Off the top of my head, here are 3 such protocols:
(Pick whichever one protocol is the easiest for you to implement).
(Please tell me about other "scalable" "simple" networking protocols,
especially non-proprietary open standards).

* daisy-chain serial SPI: (4 wires per slave; automatic baud rate
synchronization) approach used by, among other things, JTAG scan.

* decrement packet address: (2 wires per slave) each chip has a
serial-in and a serial-out pin. The host serial-out pin is connected
to the first slave serial-in pin. Each slave serial-out pin is
connected to the serial-in pin of the next slave in the chain. (The
last serial-out pin is typically connected to the serial-in pin of the
master, for loopback test purposes). When a chip receives a packet of
data on the serial-in line, it checks the destination address. If the
destination is address "00", it accepts that data as a command, turns
on lights, spins motors, activates the death ray, etc. etc. If the
destination address is any other address, the chip forwards the packet
to the next chip almost exactly. Every byte of the message is copied
the same, except for the address byte(s), which are decremented. If
the received address was "99", the chip sends "98"; if the received
address was "01", the chip sends "00". (With a bit of clever
programming, each chip does not have to wait until the entire packet
is received, but instead can start transmitting at near-wire-speed as
soon as the address byte is received). After forwarding the entire
packet, the slave immediately forgets it (in particular, it does *not*
accept that packet as a command).

* daisy-chain select, common data: (3 wires per slave) The host
serial-out pin is directly connected to every slave serial-in pin. In
addition, each chip has a select-in and a select-out pin. The host
select-out pin (which the host normally holds high) is connected to
the first slave select-in pin. Each slave select-out pin (which the
slave normally holds high) is connected to the select-in pin of the
next slave in the chain. When the slave-select line of a slave is
high, it "sleeps", ignoring the serial data line. When a slave sees
its select-in pin pulled low, it wakes up, accepts first command on
the common serial line (even if the command is "no-operation"), and
then pulls its own select-out pin low and goes back to sleep, ignoring
further commands until it is woken up again. When that slave sees its
select-in pin pulled hi, it immediately drives its own select-out pin
high and goes back to sleep. At some later time, when the slave sees
its select-in pin pulled low, it (as always) wakes up and accepts
exactly one command on the common serial line, then pulls its own
select-output line low. (Even while sleeping and ignoring most
commands on the common serial line, perhaps the slave might wake up on
the special "On my mark ... NOW!" synchronized start command addressed
to every slave).

Perhaps one of these protocols could be used to automatically assign
addresses whenever slaves are added, removed, or re-arranged, even if
some global broadcast net (transmitting addressed packets) were used
to transfer most data.

The "daisy-chain SPI" protocol has a name; do these other protocols have a name?
Is there a general name for this entire category of protocols, a
better name than "scalable" "simple" networking protocols?

--
David Cary
http://carybros.com/
http://opencircuits.com/
http://wikiindex.org/Pica-wiki
PIC/PICList FAQ: http://www.piclist.com
http://www.piclist.com/member/DAV-MP-E62a
en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
www.piclist.com/techref/postbot.asp?by=thread&id=%5BSX%5D+Bean%27s+SX28+8x8+PWM+Code+and+SX28+Addressable

2008\03\25@050151 by Michael Rigby-Jones

picon face


> -----Original Message-----
> From: spam_OUTpiclist-bouncesTakeThisOuTspammit.edu [.....piclist-bouncesKILLspamspam@spam@mit.edu] On
Behalf
{Quote hidden}

Unless I have misunderstood, all of these would appear to suffer from
increasing latency the further away from the host the slave is in the
network.  With a large number of slave devices this could be
unacceptable.

Regards

Mike

=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================

2008\03\25@161702 by Wouter van Ooijen

face picon face
>> Off the top of my head, here are 3 such protocols:
>> (Pick whichever one protocol is the easiest for you to implement).
>> (Please tell me about other "scalable" "simple" networking protocols,
>> especially non-proprietary open standards).
>> (snip)
> Unless I have misunderstood, all of these would appear to suffer from
> increasing latency the further away from the host the slave is in the
> network.  With a large number of slave devices this could be
> unacceptable.

Here I go again: for a customer I once designed a chain-of-nodes
'network'. each node can is essence block the communication to the next
no, or let is pass. Letting it does not add a significant delay. After
startup all nodes block, and the head-end gives out the addres to the
first node, the first node unblocks, the head-end assigns the next
address, etc. Worked well up to ~100 nodes. The network was larger, the
head-ends were also chained.

Wouter


'[SX] Bean's SX28 8x8 PWM Code and SX28 Addressable'
2008\04\04@022318 by David Cary
face picon face
Dear piclisters,

> Michael Rigby-Jones
>
> Unless I have misunderstood, all of these would appear to suffer from
> increasing latency the further away from the host the slave is in the
> network.  With a large number of slave devices this could be
> unacceptable.

You are right.
At best, those protocols have a latency of one or two character-times per slave.
Off the top of my head, here are 2 scalable protocols with even less
latency (after the initial boot-up time):
(Please tell me about other "scalable" "simple" networking protocols,
especially non-proprietary open standards).

* packet blocking: (2 wire per slave)
The host serial-out pin is connected to the first slave's serial-in
pin and a (practically zero-latency, compared with normal line delay)
noninverting line driver.
The output of the first slave's driver goes to the second slave's
serial-in pin and its driver... and so on.
Each slave can "block" its own line driver (forcing the driver output
to line idle, blocking communication to downstream slaves).
At power-on, all slaves block.
During bootup, the host gives out some address ("your address is now
A1"; "A1: now unblock") to the first slave, the first slave unblocks,
the host sends an address ("If you don't already have an address, your
address is now A2"; "A2: now unblock") to the second slave, and so on.
Eventually all the slaves are unblocked, and every slave can listen to
everything the master says.
>From then on (until the next reboot), the host sends packets addressed
to a specific slave (or to the special "Everyone" address).
When the host sends the "slave #FF, turn on your LED", every slave
simultaneously receives the message, but only slave #FF recognizes and
acts on the message.
(Is this "packet blocking" the same as what Wouter van Ooijen described?)

* daisy-chain select, common data: (3 wires per slave)
The host serial-out pin is directly connected to every slave serial-in pin.
In addition, each slave has a select-in and a select-out pin.
The host select-out pin is connected to the first slave select-in pin.
Each slave select-out pin is connected to the select-in pin of the
next slave in the chain.
At power-on, everyone holds their select-out pin high.
When the slave-select line of a slave is high, the slave "sleeps",
ignoring the serial data line.
During boot-up, the host pulls its select-out line low, and
gives out some address ("your address is now A1"; "A1: now pull your
select-out line low") to the first slave; the first slave pulls its
select-out line low, the host sends an address ("If you don't already
have an address, and your select-in line is low, your address is now
A2"; "A2: now pull your select-out line low") to the second slave, and
so on.
Eventually all the slaves have their select-in pin pulled low.
>From then on (until the next reboot), the host sends packets addressed
to a specific slave (or to the special "Everyone" address).
When the host sends the "slave #FF, turn on your LED", every slave
simultaneously receives the message, but only slave #FF recognizes and
acts on the message.

(So, how do the slaves communicate back to the host?)

p.s.:
With any daisy-chain network, it's probably good for both ends of the
daisy chain to connect back to the host.
That makes it easy for the host to check for breaks in the chain.

--
David Cary
http://carybros.com/
http://opencircuits.com/
http://wikiindex.org/Pica-wiki
PIC/PICList FAQ: http://www.piclist.com
http://www.piclist.com/member/DAV-MP-E62a
en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
www.piclist.com/techref/postbot.asp?by=thread&id=%5BSX%5D+Bean%27s+SX28+8x8+PWM+Code+and+SX28+Addressable

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