In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mwiht37 wrote: Greetings! I have been experiencing a lot of trouble with the SERIN command in SXb and am hoping that someone can offer some insight. __________________ The problem: __________________ I am attempting to send a byte from Visual Basic 2005 to an SX chip. The SX is attached to 8 LEDs which display the byte value in binary. If this sounds familiar, it's because it's from the SX help file. Everything seems to work fine for bytes 0 thru 127. But as soon as I hit 128 and higher, I start getting unpredictable output on the LEDs. __________________ The circuit: __________________ 1) SX chip on a parallax professional development board plugged into the designated SX socket. 2) 8 LEDs attached to pins RC.0 thru RC.7 3) RA.1 attached to pin 3 (SIN) on my computers serial port. (see attached schematic showing serial connection.) __________________ SX Code: __________________ ' ------------------------------------------------------------------------- ' Device Settings ' ------------------------------------------------------------------------- DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX FREQ 4_000_000 ' ------------------------------------------------------------------------- ' IO Pins ' ------------------------------------------------------------------------- RX PIN RA.1 INPUT 'This pin recieves the byte from the computer LEDs VAR RC 'Prepare the LEDs to output the byte TRIS_LEDs VAR TRIS_C ' ------------------------------------------------------------------------- ' Variables ' ------------------------------------------------------------------------- sData var byte 'This variable stores the byte sent from the computer ' ========================================================================= PROGRAM Start Start: TRIS_LEDs = %00000000 ' make LEDs outputs sData = 0 'start with all LEDs off Main: SERIN RX, N38400, sData 'get the byte from the computer. The help file says 38400 is the fastest rate available at 4mhz 'Yet even slower rates such as 2400 won't work LEDs = sData 'output the byte to the LEDs Goto Main 'rinse and repeat __________________ The VB2005 code: __________________ 1) Create a new project. 2) drag a serial port control from the tool box to the window 3) Keep all the properties set to default, except change the baud to match the SX code (38400) and set the comport to the right value 4) Drag a button and a textbox control to the window. 5) Double click the button and enter this code: SerialPort1.Write(Chr(TextBox1.Text)) __________________ Theory of operation: __________________ Run the VB2005 program, enter a number (zero to 255) in the text box, and click the button. VB converts the number to the corresponding ANSII character and sends it to the SX chip. The sx recieves the character in the form of a byte and outputs the numerical value to the LEDs. Once you get to 128 (and all numbers greater), however, all you get is "63" output to the LEDs (well... the binary equivalent to 63, that is) I have created extravagant workarounds to resolve this problem... but those solutions are exceeding complicated, slow, and eat up all the memory in the SX that I would rather use for other code. If anyone could tell me what I'm doing wrong, it would be greatly appreciated :) If what I am trying to do isn't possible, a less complicated solution would also be appreciated. The SX needs to be able to count from zero to 255 (all LEDs off, to all LEDs on). Thanks! ;-) ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=316547 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)