Transmitting HEX Commands to an OLED display ?
JMLStamp2p
Posts: 259
Hello All,
I am using an OLED-96-Prop to send serial data to an OLED-160 to pull up graphics Pics. out of the SD card. I have got FullDuplexSerial loaded and using the following code. Could someone tell me what the HEX modifier
is so I can make sure that I send HEX to the OLED-160.
PUB Transmit
· data.start(21,20,0,9600)················ 'rx pin = 21 : tx pin = 20 : mode : baud rate
· DELAY.PauseSec(15)
· data.tx(55)·····················'Auto Baud Command
· DELAY.PauseSec(1)
·I need to be transmitting HEX commands·here:
· data.tx(40)
· data.tx(49)
· data.tx(0)
· data.tx(0)
· data.tx(A0)
· data.tx(80)
· data.tx(10)
· data.tx(0)
· data.tx(10)
· data.tx(0)
· data.tx(7)
· data.tx(B)
· data.tx(B8)
Thanks,
JMLStamp2p
·
I am using an OLED-96-Prop to send serial data to an OLED-160 to pull up graphics Pics. out of the SD card. I have got FullDuplexSerial loaded and using the following code. Could someone tell me what the HEX modifier
is so I can make sure that I send HEX to the OLED-160.
PUB Transmit
· data.start(21,20,0,9600)················ 'rx pin = 21 : tx pin = 20 : mode : baud rate
· DELAY.PauseSec(15)
· data.tx(55)·····················'Auto Baud Command
· DELAY.PauseSec(1)
·I need to be transmitting HEX commands·here:
· data.tx(40)
· data.tx(49)
· data.tx(0)
· data.tx(0)
· data.tx(A0)
· data.tx(80)
· data.tx(10)
· data.tx(0)
· data.tx(10)
· data.tx(0)
· data.tx(7)
· data.tx(B)
· data.tx(B8)
Thanks,
JMLStamp2p
·
Comments
I have sent these same commands via a small Visual Basic program that I wrote to test the Display and it worked great. When I run the same commands through the Prop-96 to the OLED-160 it halts when it sees the Auto Baud command but then does nothing. I can see the serial data on my scope so I know that it is being transmitted and don't understand what is wrong. The data sheet on the OLED-160 says it needs app. 300ms to respond after each commandwith an ack. I sent the commands in VB
without the delay but maybe the Prop is executing faster. Mike, as you can see I am using pin 20 on the OLED-96-Prop to send the serial data out. I wouldn't assume that this line would not need to be pulled high or low and I am using a 100 ohm resistor
in series before it gets to the OLED-160. Do you see something that I am doing wrong ? I am running this code in a loop just to monitor the display ...
Can I use "waitcnt (300)" as a pause for 300 ms between each tx command ? Also,
......................................................................................................................
PUB Transmit
data.start(21,20,0,9600) 'rx pin = 21 : tx pin = 20 : mode : baud rate
DELAY.PauseSec(10)
data.tx($55) 'Auto Baud Command for the OLED-160
DELAY.PauseSec(5)
data.tx($40)
data.tx($49)
data.tx($0)
data.tx($0)
data.tx($A0)
data.tx($80)
data.tx($10)
data.tx($0)
data.tx($10)
data.tx($0)
data.tx($7)
data.tx($B)
data.tx($B8)
DELAY.PauseSec(10)
OLED.CLS
JMLStamp2p
John.
and
Thank You for your code and most of all the comments to the right. It really helps bridge
the gap from your experience and knowledge in Spin to my lack of it. I will incorperate the "ack" segment of code in my program to see if that makes a difference. I realized last night that there was no need for the in-line resistor since the output of the Prop-96 is at 3.3 volts. As far as the logic state of the Props output pins, are they interneally held Hi or Lo ? I assumed that there is no need of external Pull-up's or Pull-Down resistors, am I right ?
JMLStamp2p
John.
Is there any reason why I couldn't use Pin 30 "tx pin" of the OLED-96-Prop after the Initialization
process for serial data out to the OLED-160 ? I really need the user pins "18,19,20 & 21" of the OLED-96 for other task if possible.
John.
I believe that I may have just found my problem. I read where the output state of all Propelleer Pins
are set low on startup. I assume that I need to use:
dir[noparse][[/noparse]20] ~~
outa[noparse][[/noparse]20] ~~
I understand the OLED-160 needs to see this pin at a High logic state at the start of the serial transmission process. I will try this tonight and see if it makes a difference.
Thanks for your help,
JMLStamp2p
John.
2) Yes you can use pins 30/31 for an ordinary serial channel once your program starts. I do this in uOLED-96-Basic for the "console".
3) The output pins of the Propeller are set to input (high impedance) mode on reset. Read the datasheet. You'll see that there's a direction and an output register for each cog. They're OR'd together so, if any cog sets a pin to output, it will be an output. If any pin set to output mode has its output register set to a 1 for that pin, then the output will be a high level.
I understand, thanks for the help I believe that this will fix my problem.
JMLStamp2p
John.
OLED Problem Up-date.
I am sending the following code to an OLED-160 through a TTL level reciever and all is working fine. Strange, but my input on the recieve line is at a Low logic level on power-up and it works every time. The highlighted code are the commands that the GC provided.They are·loaded in a Visual Basic array and transmitted out the serial port through a matching transmitter.
My problem is this:
I am trying to send the same commands out of a OLED-Prop-96, I have the recieve line of the OLED-160 pulled High through a 10K pull-up resistor to prevent a false Auto Baud. On power-up the Display is showing the Flash
screen, As I monitor the data output of Pin 20 on the OLED-160-Prop "My transmit line to the OLED-160" I see the Auto Baud command being transmitted and the Flash screen haults. After the Auto Baud is recognized
I wait 3- seconds and I see the commands being sent to the OLED-160 to bring up my graphics Pic. but nothing happens !
The only differnece that I see is this:
On the Reciever circuit that is working, my logic High level on the recieve pin to the OLED-160 is at a 5V. On the circuit that is not working High logic level signal is at a 3.6V. From what I understand a High logic level to the display should be Vdd divided by 2 or 2.5V since I am using a 5V supply. Am I understanding this correctly ?
Should I use a Transistor to amplify the data coming out of my OLED-96-Prop
to a higher logic level ?
....................................................................................................
Working VB code:
....................................................................................................
Private Sub SkinButton19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SkinButton19.Click
Dim idx As Integer
Dim my_array As Byte() = New Byte(14) {&H40, &H49, &H0, &H0, &H80, &H80, &H10, &H0, &H10, &H0, &HB, &H0, &H0, &H0, &H0}
For idx = 0 To 12 'Display Object from SD card !
SerialPort1.Write(my_array, idx, 1)
Next
End Sub
......................................................................................................
Spin Code that is not working in the OLED-96-Prop:
Note: The Spin code works attached directly to the serial port on my computer through the USB to Serial adapter.
......................................................................................................
CON
· _CLKMODE····· = XTAL1 + PLL8X·······················
· _XINFREQ····· = 8_000_000
· dSlow········ = 50
· dFast········ = 20
·
OBJ
· OLED· : "uOLED-96-Prop_V4"
· DELAY : "Clock"
· DATA : "FullDuplexSerial"
VAR
· long Stack [noparse][[/noparse]9]
· byte Byte_Recieved
..................................................................................................
·
PUB MAIN
· 'dira[noparse][[/noparse]20]~~
· 'outa[noparse][[/noparse]20]~~
·
· DELAY.Init(8_000_000)
· OLED.InitOLED
· OLED.CLS
· Transmit
· 'REPEAT
· 'Johns
··
PUB Transmit
· data.start(21,20,0,9600)················ 'rx pin = 21 : tx pin = 20 : mode : baud rate
· DELAY.PauseSec(7)
· data.tx($55)
· DELAY.PauseSec(3)
· Johns
....................................................................................................
PUB Johns
· data.tx($40)·
· data.tx($49)
· data.tx($00)
· data.tx($00)·
· data.tx($80)
· data.tx($80)·
· data.tx($10)·
· data.tx($00)
· data.tx($10)·
· data.tx($00)
· data.tx($0B)·
· data.tx($00)
· data.tx($00)
· data.tx($00)
· data.tx($00)
··
·· DELAY.PauseSec(10)
·· OLED.CLS
....................................................................................................
dira[noparse][[/noparse]20]~~
outa[noparse][[/noparse]20]~~
And pulled Pin 20 high through a 10k Resistor and it works every time.
Thanks,
JOHN.