Aaaaarrrrggghhhhh :-) Serial woes

taximania

Well-Known Member
Licensed User
Longtime User
Ok, I'm finally pronounced brain dead. Been at this 2 weeks now.
Didn't want to bother you guys, (and gals ?)

I'm trying to send a byte to a Microchip Pic controlling an LCD display.
eg: 1 byte valued between 1 - 255

serial.Output(? :sign0148: ?) WHAT !!

I've tried
serial.Output(textbox1.text)
serial.Output(chr(textbox1.text))
serial.Output(int(textbox1.text))

I've tried serial.Output2(various variations)

I can't get the display to reproduce a number over 127.
128 shows 63 !
Or the ascii symbol for the byte sent.

Ascii is 0-127 ?????

:sign0082:
 

agraham

Expert
Licensed User
Longtime User
I can't get the display to reproduce a number over 127.
Yup, that's the problem with the default ASCII encoding when sending text through the Serial2 library. Serial.Output sends a String and as the standard Encoding is ASCII it won't send any character over 127. You should use Serial.Output2 which sends bytes that can have any value between 0 and 255. If you need to receive binary data then read the help for (and use) my SerialEx library.
 

taximania

Well-Known Member
Licensed User
Longtime User
Cheers for the nudge you two :sign0188:

In all my years of programming and using the Serial port,
who'd believe only now am I trying to send a value larger than 127.

I bet my other 2 graphic LCD projects might work now :sign0087:
 

taximania

Well-Known Member
Licensed User
Longtime User
For those that might read this thread.
Yup. How do you send a byte via Serial.

Declare a Global variable, eg:
B4X:
Byt(1) as byte 'Single Array with one element.


then use:

B4X:
Byt(0)=129 '0= first elemenet of array, 129 is the value to send
Serial.Output2(Byt()) 'Send the single Byte Array


It's in the desktop helpfile :sign0148:
Well, a similiar example is :)
 

taximania

Well-Known Member
Licensed User
Longtime User
Got them both working now.

Saving a 128 x 64 BMP drawn on a PPC, to a microchip 24LCxxx EEPROM has been sorted :sign0060:
Reading a 24LCxxx image back to a 128 x 64 Graphic LCD is sorted.
Not tried reading back to a PPC Image yet. One to try :)

All this is done between a PIC microcontroler with a Bluetooth module connected, and my PPC via a Bluetooth serial connection.


Yawn . . . . :sign0013:



:sign0087:
 

Cableguy

Expert
Licensed User
Longtime User
:sign0098: There's nothing like a bit of successful low level bit-twiddling with a bit of hardware to provide that warm inner glow of satisfaction and achievement (and provoke utter bewilderment on the part of the other half!).

Yeah, what he said....
 

seeyee520

Member
dose it work?

For those that might read this thread.
Yup. How do you send a byte via Serial.

Declare a Global variable, eg:
B4X:
Byt(1) as byte 'Single Array with one element.


then use:

B4X:
Byt(0)=129 '0= first elemenet of array, 129 is the value to send
Serial.Output2(Byt()) 'Send the single Byte Array


It's in the desktop helpfile :sign0148:
Well, a similiar example is :)


i had do the same work as you did .
i plan to use the PPC to control a microcontroller based of 51.
the question is all data sent by the serial is 0xF8 and 0x80,not anyting else 。
so how can i use the serial to transmit a hex data like 0x0c。???
 
Top