Serial Output
Hi,
I need to make a serial output with a 4800 bod, how do I do that? Where can I look to get help for that?
Thanks
I need to make a serial output with a 4800 bod, how do I do that? Where can I look to get help for that?
Thanks
Comments
Change Uart.speed9600 into Uart.speed4800
regards peter
thanks
thanks
thanks
You can send the lowbyte, then the highbyte of an int:
int value; //some value
tx.sendByte(value); //send lowbyte of value
tx.sendByte(value>>>8); //send highbyte of value
On the receiving end these two bytes must be assembled into an int again.
lowbyte = receive();
highbyte = receive();
value = (lowbyte&0xFF)|(highbyte<<8);
For your other questions:
Post your code so we can see what you (try to) do.
And please post it as an attachement so we can load it
into the JIDE and edit it.
regards peter
thanks
thanks
You can specify the base (decimal,octal,binary,hexadecimal,unsigned) see
pdf file for Format class.
In the attachement I used decimal, eg. binary value 12 is converted to asciiz string "12"
If your radio rquires a special start or stop character to identify the number,
just insert a tx.sendByte() before or after the asciiz string is transmitted.
You can download the Format class here:
http://groups.yahoo.com/group/JavelinCode/files/Javelin%20Stamp%20IDE/lib/stamp/util/text/
regards peter
thanks
· public static void main() {
··· int value,i;
··· while(true) {
····· CPU.delay(1000);
····· value = adc.value(); //read adc
····· Format.sprintf(buf,"%d",value);· //convert binary number to asciiz string eg. binary 12 becomes "12"
····· i = 0;
····· tx.sendByte('$'); //identify start of number
····· while (buf[noparse][[/noparse]i] != 0) {
······· txUart.sendByte(buf[noparse][[/noparse]i++]); //send next char from asciiz string
····· }
··· }
· }
To identify the end of the ascii number, you can use
tx.sendByte('!'); or whatever character you fancy (even binary 0).
If you want your numbers to have equal length, you can use
Format.sprintf(buf,"%5d",value);
Each number is then rightjustified with space padding,
eg. binary 12 becomes "·· 12"
You can also do it all in one statement
Format.sprintf(buf,"$%d ",value);
binary 12 becomes "$12 "
so the number starts after $ and stops before space.
The buf array must then have length 9 instead of 7.
regards peter
Thanks
levels (-12V and +12V). The pc expects rs232 levels.
If your radio expects TTL levels than you don't need a levelshifter.
If your radio only has a receive pin and never transmits anything,
you only need the tx pin on the javelin (which connects to
the radio receive pin, via levelshifter if necessary).
regards peter
Make sure the defined txPin is the pin connected to your radio.
Also check wether you need rs232 or TTL levels.
It could be the radio requires inverted signals.
You can try
· static Uart txUart = new Uart(Uart.dirTransmit,txPin,Uart.invert,Uart.speed4800,Uart.stop1);
regards peter