HCMS-2911 interface

johndo

Member
Hi everyone,
Having been into picaxe for only for a short time, i am in need of
some help.
I have a project where i need to display a word eg, "ALARM" on an
intelligent led display HCMS-2911.

http://web.mit.edu/6.111/www/s2004/NEWKIT/datasheets/HCMS-2973.pdf

This may help also...
http://www.avagotech.com/pc/downloadDocument.do?id=3668


Understanding the concept of how the display works is no problem,
but how to use the PICAXE to display text, is at this stage not
coming to me. I have managed to write a program that displays three
boxes that move from right to left, 10 times and then puts the
display into sleep mode, but i think i'm going the long and wrong
way about it. Perhaps someone could write a shorter example using
the word "ALARM" in so i can see how it works. This is my LONG
CODE...

activate:
if pin7= 1 then word0
goto activate

word0:
for b1= 1 to 2
pause 10
high 5 'select control register
pause 10
low 7 'chip enable
pause 10
Control word0, Brightness.
pulsout 6,250 '0 clock
high 4 data high,etc
pulsout 6,250 '1
high 4
pulsout 6,250 '1
low 4 data low,etc
pulsout 6,250 '0
high 4
pulsout 6,250 '1
high 4
pulsout 6,250 '1
high 4
pulsout 6,250 '1
high 4
pulsout 6,250 '1
high 7
pause 10
high 5
pause 10
low 7
high 4
pulsout 6,250 '1 Control word1.
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
high 4
pulsout 6,250 '1
low 4
high 7
next b1
goto main1


main1: 'Three boxes scrolling from right to left.
for b3= 1 to 10
if pin0= 1 then sleepy
low 5
pause 10
low 7
pause 10
for b2=1 to 3
for b0= 1 to 40
high 4
pulsout 6,250
next b0
pulsout 7,250
next b2
gosub clear
next b3
goto sleepy

clear: 'Clear all boxes.
pause 10
low 5
pause 10
low 7
for b2= 1 to 8
for b0= 1 to 40
low 4
pulsout 6,250
next b0
pulsout 7,250
next b2
return

sleepy:
for b1= 1 to 2
pause 10
high 5
pause 10
low 7
pause 10
low 4

'Control word0,Sleepmode.
pulsout 6,250 '0
low 4
pulsout 6,250 '0 ' this is the sleep bit
high 4
pulsout 6,250 '1
low 4
pulsout 6,250 '0
high 4
pulsout 6,250 '1
high 4
pulsout 6,250 '1
high 4
pulsout 6,250 '1
high 4
pulsout 6,250 '1
low 4
high 7
pause 10
high 5
pause 10
low 7
high 4
pulsout 6,250 '1 'Control word1.
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
low 4
pulsout 6,250 '0
high 4
pulsout 6,250 '1
low 4
high 7
next b1
pause 10
low 5
pause 10
low 7
gosub clear
goto activate

PS: Contol word0 and word1 control brightness,sleep mode etc...
i am using a picaxe 28X

Many, many thanks... Kurt
 

BarryP

Senior Member
'Ouch !!
'This is gonna be a hungry little resource Muncher.
'A quick look at the datasheet implies that there is No inbuilt Characters .
'So you are looking at a Big lookup Table.
'As Each Chr is a 40bit latch , thats 5 Bytes per Chr.
'A Lookup Table for the Basics 0..9 a..z A..Z >> 62 x 5 = 310 bytes so You are going to need an external EEPROM.

;Aside from the Lookup table stuff , Here is some untested code to get you started.
<code><pre><font size=2 face='Courier'>
;For an 8 Character Display You Might Have the Latch data Stored In MEM
;Thats 40 Bytes
Symbol LatchStoreStart = $C0
Symbol LatchStoreEnd = LatchStoreStart + 39


Symbol DataByte = B0
Symbol DataLocation = B2
Symbol X = B3
Symbol DataBit = Bit0
Symbol DataPin = 4
Symbol ClkPin = 6
Symbol CEpin = 7
Symbol RSpin = 5


FillRandomStuff:
for DataLocation = LatchStoreStart to LatchStoreEnd
random W6
Poke DataLocation,B12
next

gosub FillDisplay
goto FillRandomStuff




FillDisplay:
Low RSpin
Low CEpin
Low ClkPin
for DataLocation = LatchStoreStart to LatchStoreEnd
Peek DataLocation,DataByte

SendByte:
for X = 0 to 7
Low DataPin
If DataBit = 0 then SkipHi
High DataPin
SkipHi:
Pulsout ClkPin,1
DataByte = DataByte / 2
Next X
Next DataLocation
High CEpin

Return
</font></pre></code>

Edited by - barryp on 25/03/2006 03:04:57
 

johndo

Member
BarryP, thanks for you help...
Still a bit confused though, may have to do a &quot;bit&quot; more reading. Last night I made up some letters by:
low 4
pulsout 6,1
pulsout 6,1
high 4
pulsout 6,1
pulsout 6,1
pulsout 6,1
pulsout 6,1
pulsout 6,1
low 4
pulsout 6,1... etc,etc,etc

it works very well but takes up a lot of lines in code. I 've heard of bit masking,would this work, at least for the control words? Any more help will be appreciated...Good books?

Cheers Kurt...
 

andrewpro

New Member
I didn't spend a whole lot of time checking it out, but it seems to be just an SPI-like (or possibly true SPI) interface. You can easily use loops and bit shifting to implement it. It will reduce your code size dramatically. Check out this:

<A href='http://research.plistin.com/picaxe/picaxeSPI.html' Target=_Blank>External Web Link</a>

---andy P
 

BarryP

Senior Member
Hi
It's gonna be difficult to help you unless you can Understand this small piece of code &amp; how IMPORTANT it is in your situation.
It's a ShiftOut function.
Give it a Byte , &amp; it Serially Shifts Out 1 Bit at a Time.
<code><pre><font size=2 face='Courier'>
This is The LSB First Version
Symbol DataBit = Bit0
SendByte:
for X = 0 to 7
Low DataPin
If DataBit = 0 then SkipHi
High DataPin
SkipHi:
Pulsout ClkPin,1
DataByte = DataByte / 2
Next X


This is The MSB First Version
Symbol DataBit = Bit7
SendByte:
for X = 0 to 7
Low DataPin
If DataBit = 0 then SkipHi
High DataPin
SkipHi:
Pulsout ClkPin,1
DataByte = DataByte * 2
Next X
</font></pre></code>
What pins are connected up
Picaxe -- Display



Edited by - barryp on 25/03/2006 03:05:59
 

johndo

Member
Hi Barry,
A byte is made up of 8 bits?
but how do you tell it to shift a 1 or 0?
eg. How would you shift out this byte? 01101111

Im just a slow learner.. But i'll get there, EVENTUALLY.
Thanks for your patience...Kurt

Picaxe 28x
DATA = Pin 4
RS = Pin 5
CLOCK = Pin 6
CE = Pin 7

Edited by - johndo on 25/03/2006 00:08:03
 

BarryP

Senior Member
Hi
You Would do it this way , assuming you are shifting out form right to left ( L east S ignificant B it)
The Result will be
D=1 ,clkpulse
D=1 ,clkpulse
D=1 ,clkpulse
D=1 ,clkpulse
D=0 ,clkpulse
D=1 ,clkpulse
D=1 ,clkpulse
D=0 ,clkpulse
<code><pre><font size=2 face='Courier'>
DataByte = %01101111
gosub sendbyte



This is The LSB First Version
Symbol DataBit = Bit0 'The LSB Of B0
'Check the Pdf's . B0 &amp; B1 Are Bit Addressable Variables. B0 &gt;&gt; Bit0..Bit7 B1 &gt;&gt; Bit8.. Bit15 W0 &gt;&gt; Bit0..Bit15

SendByte:
for X = 0 to 7 ' Loop 8 Times For 8 Bits
Low DataPin ' Set The Data Pin Low
If DataBit = 0 then SkipHi 'Check The State Of The LSB
High DataPin ' The LSB Must have Been Hi(1) So Set The Data Pin Hi
SkipHi:
Pulsout ClkPin,1 ' Clock Pulse To Let The Device Accept The Data Bit .
DataByte = DataByte / 2 ' This Is Where You May Be Unstuck ..
Dividing a BYTE Bye 2 SHIFTS All The Bits To The Right By 1.
The LSB Falls Off when Shifted Right (Actually It moves to the 'CarryFlag'). Bit7 becomes 0
Next X
&lt;/font&gt;&lt;/pre&gt;&lt;/code&gt;
The MSB version does the Same type of thing , Except It uses Multiplication to SHIFT the Bits To The LEFT &amp; the Bit That Gets Shifted Out Is The MSB (Bit7)
Each Time You Divide By 2 , 'DataBit(bit0) becomes the Next Bit In The Byte


You Could Open Up Windows Calculator , Switch to Scientific View &amp; experiment with Hex Bin Calculations.

BTW , The Term LSB could be confusing ..
Someone Else May Be Able To Shed some Light.
Perhaps I should call It, LSbyte or LSbit
LSbyte would reffer to B0 of W0 &amp; MSbyte would be B1 of W0.
Clear As Mud ?

Edited by - barryp on 25/03/2006 04:25:06 </font></pre></code>
 

johndo

Member
Thanks very much barry,youv'e been a great help, starting to see the light now! Still have a lot to learn.
i'll just keep pluging away at it.
Thanks everybody else for your contribution!
Regards...Kurt
 

BarryP

Senior Member
No Prob
I Just Hope you Change Tact with your Current Experimentation To Include the Shiftout Sub.
Be It The LSbyte or MSbyte version , It's the Only Way you will achieve controlling that device without running out of code space.

Something Else To Help you along your way is a few Character Maps.

Symbol l_A = 0 :EEPROM l_A,($7E.$09,$09,$09,$7E)
Symbol l_B = 5 :EEPROM l_B,($7E.$49,$49,$49,$36)
Symbol l_C = 10 :EEPROM l_C,($7E.$41,$41,$41,$22)
Symbol l_D = 15 :EEPROM l_D,($7F.$41,$41,$41,$3E)
Symbol l_E = 20 :EEPROM l_E,($7F.$49,$49,$49,$41)
Symbol l_F = 25 :EEPROM l_F,($7F.$09,$09,$09,$01)
Symbol l_G = 30 :EEPROM l_G,($3E.$41,$41,$51,$32)
Symbol l_H = 35 :EEPROM l_H,($7F.$08,$08,$08,$7F)

These Were Taken From The datasheet link You Provided.
If You Don't want to use an external EEPROM then you could just use 0..9 &amp; A..Z plus another few to consume the 256 Bytes Available . (Thats 5 Bytes Per Chacater)
Good Luck
BIG Job For a Novice But A GREAT Way To Learn !!



Edited by - barryp on 25/03/2006 05:55:08

Edited by - barryp on 28/03/2006 04:10:41
 

johndo

Member
Hi,
Still working on this, and wrote this code to write characters from eeprom to the display,but it's only writing the first byte from memory ($7E). My question is how do you get each byte out of mem into b0 sequentially.

EEPROM 0,($7E,$09,$09,$09,$7E) 'This represents the letter &quot;A&quot;

main:
if pin7= 1 then read1
goto main

read1:
for b3 = 1 to 5
read 0,b0
pulsout 7,25
next b3
gosub sendbyte
goto main


SendByte:
for b3 = 0 to 39
Low 4
If bit7 = 0 then SkipHi
High 4
SkipHi:
Pulsout 6,25
b0 = b0 * 2
Next b3
pulsout 7,25
return

ie. grab $7E,put that into b0,write to display, grab $09, put that into b0,write to display, etc,etc , to make up one letter... Im assuming thats how it works? and if i wanted to write a 4 letter word is there a shortcut?,instead of writing lot's of read's...

From a Novice...Cheers!
 

hippy

Technical Support
Staff member
No criticism of your code, just a helpful hint ...

- Low 4
- If bit7 = 0 then SkipHi
- High 4
- SkipHi:

On a PICAXE which supports it ( you might have to choose a diferent pin depending upon PICAXE chosen ) this can be reduced to ...

- pin4 = bit7
 

johndo

Member
Hippy, thank's. It worked! Saved a few bytes of code too!

Am still in need of help with my eeprom question, if anyone can help me out..

Cheers,Kurt

 

BarryP

Senior Member
There Are Many ways to get eeprom data into a usable form.

Here is One.(I Haven't tried to compile this , It's just an example)

<code><pre><font size=2 face='Courier'>
Symbol l_A = 0 :EEPROM l_A,($7E.$09,$09,$09,$7E)
Symbol l_B = 5 :EEPROM l_B,($7E.$49,$49,$49,$36)
Symbol l_C = 10 :EEPROM l_C,($7E.$41,$41,$41,$22)
Symbol l_D = 15 :EEPROM l_D,($7F.$41,$41,$41,$3E)
Symbol l_E = 20 :EEPROM l_E,($7F.$49,$49,$49,$41)
Symbol l_F = 25 :EEPROM l_F,($7F.$09,$09,$09,$01)
Symbol l_G = 30 :EEPROM l_G,($3E.$41,$41,$51,$32)
Symbol l_H = 35 :EEPROM l_H,($7F.$08,$08,$08,$7F)


Symbol CharPos = B4
Symbol TheChar = B5

Send_Feed:
CharPos = 0
GetNextChar:
TheChar = 0
Lookup CharPos,(&quot;FEED&quot;),TheChar
if TheChar = 0 then Send_Feed_AllDone 'If Lookup Can't Fid the CharPos Then TheChar will be unchanged
If TheChar &gt; &quot;H&quot; or TheChar &lt; &quot;A&quot; then Send_Feed_Error 'Make Sure there is a location to goto !
TheChar = TheChar - &quot;A&quot; * 5 ' Set TheChar to the Start Of EEPROM for that letter

For B3 = 1 to 5
Read TheChar,B0
gosub SendByte
TheChar = TheChar + 1
Next
CharPos = CharPos + 1
goto GetNextChar


Send_Feed_Error:
SerTxd (&quot;The Letter &quot;,TheChar, &quot;Not Found&quot;,13,10)

Send_Feed_AllDone:
Return
</font></pre></code>
OOPS, Just Realized That My Previous Post Was Trying to Save Each Letter to the Same EEPROM Loc I.E.
Symbol l_H = 35 :EEPROM l_A,($7F.$08,$08,$08,$7F)
Sorry, Fixed In Above.



Edited by - barryp on 28/03/2006 04:09:09
 

BarryP

Senior Member
OR

<code><pre><font size=2 face='Courier'>

Symbol l_A = 0 :EEPROM l_A,($7E.$09,$09,$09,$7E)
Symbol l_B = 5 :EEPROM l_B,($7E.$49,$49,$49,$36)
Symbol l_C = 10 :EEPROM l_C,($7E.$41,$41,$41,$22)
Symbol l_D = 15 :EEPROM l_D,($7F.$41,$41,$41,$3E)
Symbol l_E = 20 :EEPROM l_E,($7F.$49,$49,$49,$41)
Symbol l_F = 25 :EEPROM l_F,($7F.$09,$09,$09,$01)
Symbol l_G = 30 :EEPROM l_G,($3E.$41,$41,$51,$32)
Symbol l_H = 35 :EEPROM l_H,($7F.$08,$08,$08,$7F)


B5 = &quot;F&quot;
gosub SendTheChar
B5 = &quot;E&quot;
gosub SendTheChar
B5 = &quot;E&quot;
gosub SendTheChar
B5 = &quot;D&quot;
gosub SendTheChar
End



SendTheChar:
If B5 &gt; &quot;H&quot; or B5 &lt; &quot;A&quot; then Send_Char_Error 'Make Sure there is a location to goto !
B5 = B5 - &quot;A&quot; * 5 ' Set TheChar to the Start Of EEPROM for that letter

For B3 = 1 to 5
Read B5,B0
gosub SendByte
B5 = B5 + 1
Next
Return
Send_Char_Error:
sertxd (&quot;ERROR&quot;,13,10)
return
</font></pre></code>




Edited by - barryp on 28/03/2006 04:33:34
 

BarryP

Senior Member
mmm
As I Mentioned In my original reply , The Device Is Going to Chew Up a Lot Of Resouces.
To House all the Character Maps &amp; a heap of Strings to display , You are probably going to have to include an External I2C eeprom.
Then You will be writeing More Code ,Just to fill the EEPROM.
If You get to that stage, I have an Excel Spread sheet that takes the ENDLESS copy/Paste out of writing a &quot;FILL EEPROM&quot; Basic Code.
With the Help of some Forum members , I managed to get it working soas it accounted for the EEPROM Pages/Blocks.
It's not very Clearly written , so I'd need to tidy it up before sending it on.

Or perhaps see if they have have any similar displays with a character encoder 'Built In'
 
Top