PDA

View Full Version : SEROUT Hex Numbers



halju
02-23-2010, 10:50 AM
Hello everyone, its my first time using the BS2 and its prolly a noob question but im having some trouble with SEROUT hex numbers here's what my code looks like...

VarHeaderCombo VAR Word

VarHeaderCombo = $0466


SEROUT 16, 188, [VarHeaderCombo]


and my output is...

Byre Received at 9:49:35 PM : 48 msec: 66


I've declared it a "Word" so i would think i should get all 4 digits, however as you can see im only getting "66"

Can someone shed some light on this?

thanks!!!

Franklin
02-23-2010, 11:04 AM
Serout outputs Bytes so to get a word out you need two outputs. Take a look at the help file in the editor for the serout (and serin) commands for help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

halju
02-23-2010, 08:59 PM
well is there any way to get them to send with out a delay? for example

SEROUT 16, 188, [VALUE, VALUE]

This will send the two bytes like you mentioned but it will put about 100msec delay between. This was what i tried first.

Im trying to send commands to a x10 powerline controller and it wants 0x04 0x66 basically at the same time. I scanned the manual for a concatenate function however i didnt see one.

thanks,
Josh

Amaral
02-23-2010, 09:32 PM
I never timed it, but you can try "STR ByteArray {\L}" and check if it goes without this delay in between

halju
02-23-2010, 11:25 PM
Amaral - Thanks. I tried it but, it sends each byte in the string separately 100msecs apart

So there is no way to concatenate? or to serout 3 bytes at once?

Post Edited (halju) : 2/23/2010 3:37:50 PM GMT

Tracy Allen
02-24-2010, 12:36 AM
In the array form I've seen an extra delay of 150 microseconds. (That from the end of first stop bit to leading edge of next start bit) At 4800 baud, that amounts to less than one extra stop bit. I'm surprised that the controller is that picky. Direct concatenation of 1 stop bit would be as close as they could be to "at the same time".


x VAR Word
x0 VAR x.byte0
x=$4066
SEROUT 16, 188, [ STR x\2] ' ==> ~1.72 stop bits

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

halju
02-24-2010, 04:45 AM
Thanks, i'll give this a try! and yes, the controller is very picky. Its been the biggest headache project i've ever tried.

halju
02-24-2010, 11:20 AM
Tracy- so i tried that piece of code you gave me. Its still outputting...
Byre Received at 10:18:11 PM : 326 msec: 66
Byre Received at 10:18:11 PM : 426 msec: 0
Byre Received at 10:18:11 PM : 532 msec: 0

is this what i should be getting?

Tracy Allen
02-24-2010, 01:21 PM
I'm not familiar with the controller. What is $4066 supposed to do?

The statement as written will send out first the $66 and then the $40. What happens if you send it $6640 instead of $4066? What happens if you send it
SEROUT 16, 188, [HEX4 $4066] ' 4 ascii hex bytes instead of 2 binary bytes
That is, you have to be sure of the format. It might expect BCD, huh?

In the message, "Byre Received at 10:18:11 PM : 326 msec: 66"?, what does the 326 msec signify? The messages seem to be about 100 milliseconds apart.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

halju
02-24-2010, 08:55 PM
The controller wants to receive...
[0x04] [0x66] - Address A1 (A1 is a house code, device code)

I have a homemade program similar to hyper terminal, i've "talked" to the controller. So i know it will only accept HEX numbers, and i know how fast it wants the numbers.

"In the message, "Byre Received at 10:18:11 PM : 326 msec: 66"?, what does the 326 msec signify?"

That is a output from my home made program. I connect the bs2 to this program so i can see what exactly im sending, the format its sending, and how fast they are sending.

PJ Allen
02-24-2010, 09:12 PM
"Im trying to send commands to a x10 powerline controller "

There is an "XOUT" command.· Is it inappropriate?

Unsoundcode
02-25-2010, 06:39 AM
Hi Josh , is there an error in your "home made program" that you should receive 66,0 and 0 I was wondering why it never registered the 4 and why it suggested it received 3 bytes instead of two.
I'm not familiar with the X 10 protocol but did look at a few docs and did come across the exact example you quote , the docs that I read indicated that after the header (Ox4 , Ox66) the device would return a checksum (Ox6A). Did you try sending the header to the device and seeing if the device returned anything



VarHeaderCombo VAR Byte(2)
VarHeaderCombo(0) = $04
VarHeaderCombo(1) = $66
SEROUT 16, 188, [STR VarHeaderCombo\2]

the code above will transmit the header as the protocol requires, it just needs a SERIN to follow and capture the checksum if it comes

Jeff T.

EDIT: another thought , using the programming port for communication the Stamp will echo back the data it receives , if the device is frequently sending data to· the Stamp the echo·may confuse the device. Something to consider.

Post Edited (Unsoundcode) : 2/24/2010 11:01:25 PM GMT