PDA

View Full Version : shiftout to vfd problem



DDDvvv
- 1st November 2010, 03:44
hi everyone, i have this 20x2 vfd that is driven by four uln5812 vfd drivers. each uln5812 is a 20 bit shift register. two of the drivers take care of the 40 grids, and the other two take care of the 35 segments (5x7 dot matrix). it took me all day to map the bits to segments/grids, and i shifted out static characters on individual grids.

here's where the fun starts; i need to scan the grids, and this is the approach im trying;

grid var bit[40]

500 hz interrupt routine pseudocode:
grid[40] = grid[40] << 1


will this work? can i shift bits in a 40 bit variable?
quest two:

i need to load this 40 bits onto 5 bytes that will be shifted out to the grid drivers:


grid1 var byte
grid2 var byte
grid3 var byte
grid4 var byte
grid5 var byte

shiftout portd.0, portd.1, msb[grid1\8, grid2\8, grid3\8, grid4\8, grid5\8]

how do i load the bits in grid[40] onto grid1, grid2, grid3, grid4, grid5?
in short, what is the easiest way to do a 40 bit scan, and then load it onto the 5 bytes?
im putting a lot of effort on this code project because i just snagged 16 of this vfd displays at a repo/surplus auction for $5. (they are inside some omni 490 credit card machines). so its worth it. thanks for reading

HenrikOlsson
- 1st November 2010, 06:11
Hi,
Create a byte array and index the individual bits in that instead of the other way around. Have a look at Melanies excelent write up (http://www.picbasic.co.uk/forum/showthread.php?t=544) on how to access whatever within whatever (almost).

/Henrik.

DDDvvv
- 4th November 2010, 13:58
grid var byte[5]
scan var byte

;timer 0 interrupt routine
BUTTONS:
GRID.0(SCAN) = 0
IF SCAN >= 39 THEN
SCAN = 0
ELSE
SCAN = SCAN + 1
ENDIF
GRID.0(SCAN)= 1



i managed to get this routine to scan the grids, and im able to display characters. however, the above piece of code prevents the program from going to the main program. so im forced to put the whole routine into the "buttons:" interrupt.

if i comment this exact piece of code, both main and interrupt routines run, but no scanning, ofcourse. i read up on the << shift command, and that can only go from 0 to 31. (i need 40)

is there any other way to increment the bits in a byte array?
thanks

DDDvvv
- 4th November 2010, 16:02
i forgot; this is in a 18f4431 running at 40mhz. i also tried all kinds of different speeds, but same results; program on main routine will not run



BUTTONS:
GRID.0(SCAN) = 0
IF SCAN >= 39 THEN
SCAN = 0
ELSE
SCAN = SCAN + 1
ENDIF
GRID.0(SCAN)= 1


after more troubleshooting, i found out that its the line highlighted with red that's causing the program not to go to the main loop. any workaround?

bearpawz
- 6th November 2010, 04:30
Well, dont know if this helps at all, but here is how I did it with a 16 segment 10 character display.

I created a word size variable for the 16 segments. There was a look up table to determine which segments to light. Lets say that variable is seg

Then I had 10 bits for the grids, so lets say that was named grid. since it is more than 8 bits I also made that a word variable

So, to shift out my code I used:

Shiftout data,clk,mode [seg/16,grid/16]

Now to make this more applicable lets say I had a VFD with 20 characters on a 10x2 grid. I could name the first 10 grids grid1 and the 2nd 10 grid2

shiftout data,clk,mode [seg/16,grid1/16,grid2/16]

That shifts out a total of 48 bits.


My problem is figuring out how to get the proc to do other tasks while its still shifting out data. I cant recall the whole code right off but if I recall because the pic was doing all the character generation even with it doing nothing but updating the display it would either be too dim or there would be too much flicker.