Serial Communication with HV5812

airton65

Member
Hi Guys,
I'm trying to drive a couple of VDF tubes with a HV5812 but I have no idea how to communicate with the HV5812 with a picaxe. The circuit examples I have seen use clock, data and strobe inputs and apart from that I have no experience, nor can I find any information on how to do it,
Can anybody give me an idea of where to start?
Thanks in advance
Tony
 

airton65

Member
Hi eclectic, thanks for the quick response. I just had a look at that link you posted and while I don't understand much of it at the moment, I'll copy and paste it into a picaxe and see if I can get it working. I have the data sheet for the HV5812 but I don't seem to be able to post it.
 

airton65

Member
Hi, can anybody tell me what the following program is actually doing?

symbol dgt1=b2
symbol dgt2=b3
symbol outbyte=w2
symbol LSB=b4
symbol MSB=b5
setfreq em16

main:

dgt1=80 '6 bytes buffer, 80-85'
A1: peek dgt1,LSB
dgt1=dgt1+1
peek dgt1,MSB
spiout 1,3,0,(outbyte/16) 'shift buffer'
dgt1=dgt1+1 'next byte prep
pulsout 2,1
if dgt1=<85 then A1
goto main

I can see that the picaxe is outputting data but I see nothing on the outputs of the HV5812
Thanks
Tony
 

hippy

Technical Support
Staff member
The code outputs three sets of word data to the HV5812. Those words would be stored in the PICAXE RAM occupying locations 80 through 85 before the routine is called and executed.
 

airton65

Member
Hi Hippy,
Thanks for replying. I've added some data to RAM locations 80 to 85. Should I be seeing some of the outputs on the HV5812 going high or low? I'm not seeing anything. I can't seem to find any info on the web or elsewhere on how to set this up. I've added the code I'm using.symbol dgt1=b2
symbol dgt2=b3
symbol outbyte=w2
symbol LSB=b4
symbol MSB=b5
setfreq 16
output B.1,B.3



main:
let w3 = %0101010101010101
let w4 = %1111111111111111
let w5 = %1101101101101101
poke 80, word w3
poke 82, word w4
poke 84, word w5
dgt1=80 '6 bytes buffer, 80-85'
A1: peek dgt1,LSB
dgt1=dgt1+1
peek dgt1,MSB
spiout B.1,B.3,0,(outbyte/16) 'shift buffer'
dgt1=dgt1+1 'next byte prep
pulsout B.2,1
if dgt1=<85 then A1
goto main

Thankyou
Tony
 

hippy

Technical Support
Staff member
I would have expected the outputs to be showing something. You can check the values being output by placing a SERTXD or DENUG before the SPIOUT command.

If the correct data is being output but the HV5812 outputs are not changing it could be that the circuit is not wired to match the code, the code is incomplete, or possibly that the HV5812 is not functional.

Perhaps post a photo of your hardware setup and members can check that the wiring looks correct.
 

airton65

Member
Thanks Hippy, ok, if you expect some sort of output then at least I'm on the right track, I'll double check my wiring and and put the debug command in, if that fails then I'll post a photo.
Thanks very much for your time
Tony
 

airton65

Member
Hi,
It works,,,,Hooray,, and thanks for all your help. I thought if you expected something to be happening then I was on the right track so I wrote some simple code and it all came together. I was now wondering in order to drive the VFD tubes which are much like seven segment displays, albeit higher voltages ect, I need to light up certain sections of the display in order to display individual digits. Am I better trying to use a lookup table or just use subroutines for this?
Here is the code I used to get the Picaxe 18X2 communicating with the HV5812

Main:

let b1 = b1 +1
let b2 = %00000000
let b3 = %11111111
spiout B.1,B.3,1,(b1, b2, b3); HV5812 seems to output b3 then b2 then b1
pulsout B.2,10
pause 30

goto main

Thanks again
Tony
 

BeanieBots

Moderator
Depends on what is important to you. Speed, code space, read-ability etc. Whatever works. There is no "correct" method.
Personally, I would probably use EEPROM as a lookup using the value to display to form the address as this is likely to be most code efficient.
If space is not an issue, then consider a single subroutine and a SELECT/CASE structure for ease of reading.
 

airton65

Member
Hi BeanieBots, thanks for the reply. I'm only building a VFD thermometer so speed isn't an issue, but I do these little projects as a learning experience as much as anything, so I'll go down the eeprom route and see if I can get my head around that. Last night I shorted the filament to 25v,, spectacular,,, but it doesn't work now,,, money off to Russia
 

BeanieBots

Moderator
My sympathies are with you. Nothing more frustrating than when you break something on a project and you can't progress. Even worse when you know it was your own fault!
Hope it arrives soon and all goes well.
Let us know the final outcome.
 

airton65

Member
Your right there, I can't believe I was so stupid. Anyway it will give me time to play around with the code, and I'll let you know how it goes.
Regards
Tony
 

airton65

Member
Hi All, I'm finally getting back to this project, I just took a look at the date which I last posted, work really does get in the way of life. I got the spiout command working nicely with the 28X2 Picaxe I was using but now I am trying to get the HV5812 communicating with a 20M2 or hopefully a 14M2 since it is only a thermometer I'm building. I have it breadboarded and have 20 LEDS on the 20 outputs of the HV5812. I have copied the sub routines from the manual 2 spiout commands and have it working except I had to add a strobe output. My question is how do I input 20 bits of data into the HV5812 so as to get the corresponding outputs? Here is my code I'm playing with.
Code:
; ~~~~~ SYMBOL DEFINITIONS ~~~~~
; Required for all routines. Change pin numbers/bits as required.
; Uses variables b7-b13 (i.e. b7,w4,w5,w6). If only using 8 bits
; all the word variables can be safely changed to byte variables.
;
;***** Sample symbol definitions *****
symbol sclk = B.7 ; clock (output pin)
symbol sdata = B.5 ; data (output pin for shiftout)
symbol serdata = input7 ; data (input pin for shiftin, note input7
symbol counter = b7 ; variable used during loop
symbol mask = w4 ; bit masking variable
symbol var_in = w5 ; data variable used durig shiftin
symbol var_out = w6 ; data variable used during shiftout
symbol var_out2 = b14
symbol bits = 20 &#8216; number of bits
symbol MSBvalue = 512 ; MSBvalue
;(=128 for 8 bits, 512 for 10 bits, 2048 for 12 bits)
low B.5,b.6,b.7
Main:
for w13 =0 to 2046 
let w6 = w13
gosub shiftout_MSBFirst
pause 50
next w13


goto Main

 
shiftout_MSBFirst:
		for counter = 1 to bits 		; number of bits
		mask = var_out & MSBValue 		; mask MSB
		high sdata &#8216; data high
		if mask = 0 then skipMSB
		low sdata 					; data low

skipMSB:
		 pulsout sclk,1 				; pulse clock for 10us
		 var_out = var_out * 2 			; shift variable left for MSB
		next counter
		pulsout B.6,10				; I added this strobe output
			return


Would anyone be able to tell me if it is possible to output the 20 bits of data to the HV5812 using the 20M2 otherwise I'll use a 20X2
Thankyou
Tony
 
Last edited:

BeanieBots

Moderator
Glad to see you're back up and running but a shame nobody got back to you.
It should be possible (one way or another) to use any PICAXE to send serial data but the X series offer hardware and extra commands to make life easier and code run quicker.
Hopefully, somebody will be able to give you a more specific answer to your question than I can.
 

airton65

Member
Thanks for your reply Beaniebots. I finally did work out how to drive the 20 outputs of the HV 5812. I did post the code but it obviously didn't upload. I ended up uploading the 20 bits of data in 2 lots of 10 bits. I will try and repost the code when i get back to civilisation
 
Top