Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : 7 segment displays
Author | Message | ||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
I have a program that outputs to an LCD display but it is not readable at a distance so I want to use 7 segment displays. I have done this before some years ago, and remember that I loaded a Hex number into the RA, RB port etc to set the bits to display the wanted number on the display. Is there a way to do this in MM basic or do I have to use the 'pin' command to set each one individually. I havn't done much programming for the last 20 years and am a bit rusty, and things have changed, so please bare with me. Palcal. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139 |
PalCal, How do you send commands to the lcd display, spi, or i2c? If you are using spi then you can connect a 74HC595 shift register chip via the spi, with its outputs sent to the seven segment display unit. You will need a 74HC595 for each unit in the display bank. You feed the output from the first 74hc595 to the second chips input, and so on as you daisy chain the display together. Then to activate a certain character, you send the bitwise command to the display via spi. If you have 4, 7 segment displays, then you need to send 4 commands. I usually just resend the entire 4 characters... Backshed Previous thread about 74hc595 I also use a couple of DMD panels from freetronics. 16 leds high x 32 leds wide, spaced 10 mm apart(16cmx32cm) with a command added to the source v3.2, working on a v4.0 version, that mirrors the vga display to the panel, in under a few milliseconds. Regards MM_Wombat Keep plugging away, it is fun learning But can be expensive (if you keep blowing things up). Maximite, ColourMaximite, MM+ |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
I have the hardware already built. I'm using 70mm displays so have to run them from 12v. using transistors. I have 6 displays so have seven lines for the anodes and six for the cathodes to switch the segments on and off. At the moment I'm using the routine from the MM library to run an LCD. To program the ten numbers will take 7 instructions per number. I remember in assembler I could just load $3F into port B and I would have a zero, or in Picbasic I could use a lookup table and 'Poke PortB,$3F'. I was just wondering if there was an easier way in MM basic other than programming pin by pin. Palcal. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1425 |
Nothing in MMBasic for 8-bit port control. Make a subroutine for that. Micromites and Maximites! - Beginning Maximite |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
If you could manage to put a bit more hardware between your displays and the MM you could have an easier time getting it going. There are chips around that can interface with SPI to the Maximite and can be loaded with what you wish to display, what brightness & decimal point. Once you do that the MM can go away and do other things. Have a look at these links. http://www.maximintegrated.com/datasheet/index.mvp/id/1339 http://www.maximintegrated.com/datasheet/index.mvp/id/3195 |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
Thanks for the help don't know about the MAX------ chips though, my large displays have 4 LEDs per segment and need to run off 12v. I will look into it. Thanks Palcal. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
There is not a command to output 8 bits at once. The best way to do what you want in software is to create a subroutine similar to the sub LCD_Nibble() in LCD.BAS in the MM Library. That way you have the convenience of a single call to output the data. Inside the sub you would have a series of commands to set each pin but that is not really an issue when you look at it. If there were eight pins to set and it took about 30uS for each command, the overall time to output the byte would be 0.25mS. Fast enough for your purpose. Geoff Geoff Graham - http://geoffg.net |
||||
palcal Guru Joined: 12/10/2011 Location: AustraliaPosts: 1873 |
Thanks Geoff, I will go that way. Palcal. "It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all" |
||||
mariae71 Regular Member Joined: 22/08/2012 Location: SwedenPosts: 43 |
I recently hooked up some 7 segment displays to my DuinoMite, used a 4026B that has a decade counter with 7-segment display driver, that chip only needs two pins per display from the microcontroller, count and reset (plus gnd ofcourse). 2 x DuinoMite Mega 1 x DuinoMite eMega |
||||
Downwind Guru Joined: 09/09/2009 Location: AustraliaPosts: 2333 |
Personally i like I2C devices for this application and a good chip to suit is the SAA1064. data sheet......... 2012-11-11_065348_SAA1064.pdf Pete. Sometimes it just works |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
BobD, Have you made up a test circuit using the MAX chips and driving it with SPI. I'd be keen to see your efforts if you have. Regards Talbit Talbit |
||||
BobD Guru Joined: 07/12/2011 Location: AustraliaPosts: 935 |
No I haven't. I was looking for a seven segment decoder some time back and I thought what a useful chip it could be. I was looking to drive multiple 7 segments. I never did it. Well, not so far. The other way of doing what you want could be to use the PCF8574 as found by jman in another post here. You would need one for each 7 seg display and you just plug them together. Each one is individually addressable. |
||||
MM_Wombat Senior Member Joined: 12/12/2011 Location: AustraliaPosts: 139 |
Hi, I used the AS1107 chip from Austria Micro systems, which controls 8 seven segment displays or 1 8x8 led matrix. I used the spi interface to display scrolling characters on three 8x8 displays. A video is available for viewing HERE .. Video file is 47.4 Mb.. And my code.. mytext$=" Maximite by Geoff Graham, MMBasic V3.2 . Program by Dennis Wyatt."
SetPin 18, 2 'set rx pin AS a digital input SetPin 19, 8 'set tx pin AS an output Pin(20) = 1 : SetPin 20, 8 ' set clk pin high THEN set it AS an output Pin(17) = 1 : SetPin 17, 8 'pin 17 will be used AS the enable signal Cls hex1 = 0 : test1 = 0 Option base 0 Dim blink(3) : blink(0)=160 : blink(1)=176 : blink(2)=144 blinker=0 pausetime=51 Dim bcodeHEX(2) : bcodeHEX(0)=0 : bcodehex(1)=4 Dim displaydigit0(1500) ' 250 Characters 6 column wide Dim characters(96,5) GoSub dataread GoSub builddisplaydata leadingzeroes$="000000000000" 'setup chips temp1=&H0900 ' no decode mode temp2=temp1 temp3=temp1 GoSub senddata temp1=&H0b07 ' scan limit temp2=temp1 temp3=temp1 GoSub senddata temp1=&H0A04 'intensity global temp2=temp1 temp3=temp1 GoSub senddata temp1=&H0C81 ' wake up temp2=temp1 temp3=temp1 GoSub senddata Do text$=Inkey$ If text$="3" Then 'test display test1=Not test1 temp1=&H0F00 + test1 temp2=temp1 temp3=temp1 GoSub senddata EndIf If text$="8" Or text$="q" Then 'shutdown temp1=&H0C80 temp2=temp1 temp3=temp1 GoSub senddata If text$="q" Then End EndIf If text$="b" Then 'blink blinker=(blinker + 1) Mod 3 GoSub buildfeature temp2=temp1 temp3=temp1 GoSub senddata EndIf 'write all digits then increment textpos to scroll text temp1=&H0100+displaydigit0(textpos Mod scrollcount) temp2=&H0100+displaydigit0((textpos+8) Mod scrollcount) temp3=&H0100+displaydigit0((textpos+16) Mod scrollcount) GoSub senddata temp1=&H0200+displaydigit0((textpos+1) Mod scrollcount) temp2=&H0200+displaydigit0((textpos+9) Mod scrollcount) temp3=&H0200+displaydigit0((textpos+17) Mod scrollcount) GoSub senddata temp1=&H0300+displaydigit0((textpos+2) Mod scrollcount) temp2=&H0300+displaydigit0((textpos+10) Mod scrollcount) temp3=&H0300+displaydigit0((textpos+18) Mod scrollcount) GoSub senddata temp1=&H0400+displaydigit0((textpos+3) Mod scrollcount) temp2=&H0400+displaydigit0((textpos+11) Mod scrollcount) temp3=&H0400+displaydigit0((textpos+19) Mod scrollcount) GoSub senddata temp1=&H0500+displaydigit0((textpos+4) Mod scrollcount) temp2=&H0500+displaydigit0((textpos+12) Mod scrollcount) temp3=&H0500+displaydigit0((textpos+20) Mod scrollcount) GoSub senddata temp1=&H0600+displaydigit0((textpos+5) Mod scrollcount) temp2=&H0600+displaydigit0((textpos+13) Mod scrollcount) temp3=&H0600+displaydigit0((textpos+21) Mod scrollcount) GoSub senddata temp1=&H0700+displaydigit0((textpos+6) Mod scrollcount) temp2=&H0700+displaydigit0((textpos+14) Mod scrollcount) temp3=&H0700+displaydigit0((textpos+22) Mod scrollcount) GoSub senddata temp1=&H0800+displaydigit0((textpos+7) Mod scrollcount) temp2=&H0800+displaydigit0((textpos+15) Mod scrollcount) temp3=&H0800+displaydigit0((textpos+23) Mod scrollcount) GoSub senddata textpos=textpos+1 ' If textpos =65000 Then textpos=textpos-65000 Pause pausetime If text$="i" Then Print "Please enclose in quotes, for punctuation to be displayed" Input "Enter text "; mytext$ Print Len(mytext$) GoSub builddisplaydata EndIf If text$="p" Then pausetime = (pausetime +10) Mod 200 Print pausetime EndIf Loop senddata: ' rem Pin(17) = 0 'assert the enable line (active low) Timer = 0 junk1 = SPI(18, 19, 20, temp3, H, 0, 16) 'send the command junk1 = SPI(18, 19, 20, temp2, H, 0, 16) 'send the command junk1 = SPI(18, 19, 20, temp1, H, 0, 16) 'send the command tempcount=(tempcount+1) Mod 256 junk2 = SPI(18,19,20,tempcount,H,0,8) Pin(17) = 1 'deselect the slave ' duration=Timer ' datasent1=temp1: datareturned1 = junk1 ' temp = temp1 : junk = junk1 ' datasent=temp : datareturned=junk ' zerotemp$= Right$(leadingzeroes$,16-Len(Bin$(temp))) ' zerojunk$= Right$(leadingzeroes$,16-Len(Bin$(junk))) ' Print " "; zerotemp$+Bin$(temp) ' Print " "; zerojunk$+Bin$(junk) ' Print "Duration = ";duration;" mS" ' Print Hex$(datasent);",";Hex$(datareturned) ' Print "-------------------------" Return buildFeature: temp1=&H0E00 temp1= temp1 Or bcodehex(hex1) temp1= temp1 Or blink(blinker) Return Dataread: For i= 0 To 95 For j= 0 To 4 Read a characters(i,j)= a Next j Next i Return Data &b00000000, &b00000000, &b00000000, &b00000000, &b00000000 ' space Data &b00000000, &b00000000, &b01111001, &b00000000, &b00000000 ' exclamation_mark Data &b00000000, &b01110000, &b00000000, &b01110000, &b00000000 ' double_quotes Data &b00010100, &b01111111, &b00010100, &b01111111, &b00010100 ' hash Data &b00010010, &b00101010, &b01111111, &b00101010, &b00100100 ' dollar_sign Data &b01100010, &b01100100, &b00001000, &b00010011, &b00100011 ' percent Data &b00110110, &b01001001, &b01010101, &b00100010, &b00000101 ' ampersand Data &b00000000, &b01010000, &b01100000, &b00000000, &b00000000 ' apostrophe Data &b00000000, &b00011100, &b00100010, &b01000001, &b00000000 ' left_parenthesis Data &b00000000, &b01000001, &b00100010, &b00011100, &b00000000 ' right_parenthesis Data &b00010100, &b00001000, &b00111110, &b00001000, &b00010100 ' asteriska Data &b00001000, &b00001000, &b00111110, &b00001000, &b00001000 ' plus Data &b00000000, &b00000101, &b00000110, &b00000000, &b00000000 ' comma Data &b00001000, &b00001000, &b00001000, &b00001000, &b00001000 ' minus Data &b00000000, &b00000011, &b00000011, &b00000000, &b00000000 ' full_stop Data &b00000010, &b00000100, &b00001000, &b00010000, &b00100000 ' forward_slash Data &b00111110, &b01000101, &b01001001, &b01010001, &b00111110 ' zero Data &b00000000, &b00100001, &b01111111, &b00000001, &b00000000 ' one Data &b00100001, &b01000011, &b01000101, &b01001001, &b00110001 ' two Data &b01000010, &b01000001, &b01010001, &b01101001, &b01000110 ' three Data &b00001100, &b00010100, &b00100100, &b01111111, &b00000100 ' four Data &b01110010, &b01010001, &b01010001, &b01010001, &b01001110 ' five Data &b00011110, &b00101001, &b01001001, &b01001001, &b00000110 ' six Data &b01000000, &b01000111, &b01001000, &b01010000, &b01100000 ' seven Data &b00110110, &b01001001, &b01001001, &b01001001, &b00110110 ' eight Data &b00110000, &b01001001, &b01001001, &b01001010, &b00111100 ' nine Data &b00000000, &b00110110, &b00110110, &b00000000, &b00000000 ' colon Data &b00000000, &b00110101, &b00110110, &b00000000, &b00000000 ' semicolon Data &b00001000, &b00010100, &b00100010, &b01000001, &b00000000 ' less_than Data &b00010100, &b00010100, &b00010100, &b00010100, &b00010100 ' equals Data &b00000000, &b01000001, &b00100010, &b00010100, &b00001000 ' greater_than Data &b00100000, &b01000000, &b01000101, &b01001000, &b00110000 ' question_mark Data &b00100110, &b01001001, &b01001111, &b01000001, &b00111110 ' at Data &b00111111, &b01000100, &b01000100, &b01000100, &b00111111 ' A Data &b01111111, &b01001001, &b01001001, &b01001001, &b00110110 ' B Data &b00111110, &b01000001, &b01000001, &b01000001, &b00100010 ' C Data &b01111111, &b01000001, &b01000001, &b00100010, &b00011100 ' D Data &b01111111, &b01001001, &b01001001, &b01001001, &b01000001 ' E Data &b01111111, &b01001000, &b01001000, &b01001000, &b01000000 ' F Data &b00111110, &b01000001, &b01001001, &b01001001, &b00101111 ' G Data &b01111111, &b00001000, &b00001000, &b00001000, &b01111111 ' H Data &b00000000, &b01000001, &b01111111, &b01000001, &b00000000 ' I Data &b00000010, &b00000001, &b01000001, &b01111110, &b01000000 ' J Data &b01111111, &b00001000, &b00010100, &b00100010, &b01000001 ' K Data &b01111111, &b00000001, &b00000001, &b00000001, &b00000001 ' L Data &b01111111, &b00100000, &b00011000, &b00100000, &b01111111 ' M Data &b01111111, &b00010000, &b00001000, &b00000100, &b01111111 ' N Data &b00111110, &b01000001, &b01000001, &b01000001, &b00111110 ' O Data &b01111111, &b01001000, &b01001000, &b01001000, &b00110000 ' P Data &b00111110, &b01000001, &b01000101, &b01000010, &b00111101 ' Q Data &b01111111, &b01001000, &b01001100, &b01001010, &b00110001 ' R Data &b00110001, &b01001001, &b01001001, &b01001001, &b01000110 ' S Data &b01000000, &b01000000, &b01111111, &b01000000, &b01000000 ' T Data &b01111110, &b00000001, &b00000001, &b00000001, &b01111110 ' U Data &b01111100, &b00000010, &b00000001, &b00000010, &b01111100 ' V Data &b01111110, &b00000001, &b00001110, &b00000001, &b01111110 ' W Data &b01100011, &b00010100, &b00001000, &b00010100, &b01100011 ' X Data &b01110000, &b00001000, &b00000111, &b00001000, &b01110000 ' Y Data &b01000011, &b01000101, &b01001001, &b01010001, &b01100001 ' Z Data &b00000000, &b01111111, &b01000001, &b01000001, &b00000000 ' left_square Data &b00100000, &b00010000, &b00001000, &b00000100, &b00000010 ' back_slash Data &b00000000, &b01000001, &b01000001, &b01111111, &b00000000 ' right_square Data &b00010000, &b00100000, &b01000000, &b00100000, &b00010000 ' circumflex Data &b10000000, &b10000000, &b10000000, &b10000000, &b10000000 ' underscore Data &b00000000, &b01000000, &b00100000, &b00010000, &b00000000 ' grave_accent Data &b00000010, &b00010101, &b00010101, &b00010101, &b00001111 ' a Data &b01111111, &b00001001, &b00001001, &b00001001, &b00000110 ' b Data &b00001110, &b00010001, &b00010001, &b00010001, &b00010001 ' c Data &b00000110, &b00001001, &b00001001, &b00001001, &b01111111 ' d Data &b00001110, &b00010101, &b00010101, &b00010101, &b00001101 ' e Data &b00000000, &b00001000, &b00111111, &b01001000, &b00100000 ' f Data &b00001001, &b00010101, &b00010101, &b00010101, &b00011110 ' g Data &b01111111, &b00001000, &b00001000, &b00001000, &b00000111 ' h Data &b00000000, &b00000000, &b00101111, &b00000000, &b00000000 ' i Data &b00000010, &b00000001, &b00000001, &b01011110, &b00000000 ' j Data &b00000000, &b01111111, &b00000100, &b00001010, &b00010001 ' k Data &b00000000, &b01000001, &b01111111, &b00000001, &b00000000 ' l Data &b00011111, &b00010000, &b00001110, &b00010000, &b00011111 ' m Data &b00011111, &b00001000, &b00010000, &b00010000, &b00001111 ' n Data &b00001110, &b00010001, &b00010001, &b00010001, &b00001110 ' o Data &b00011111, &b00010100, &b00010100, &b00010100, &b00001000 ' p Data &b00001000, &b00010100, &b00010100, &b00010100, &b00011111 ' q Data &b00011111, &b00001000, &b00010000, &b00010000, &b00001000 ' r Data &b00001001, &b00010101, &b00010101, &b00010101, &b00010010 ' s Data &b00010000, &b00010000, &b01111110, &b00010001, &b00010010 ' t Data &b00011110, &b00000001, &b00000001, &b00000001, &b00011110 ' u Data &b00011100, &b00000010, &b00000001, &b00000010, &b00011100 ' v Data &b00011110, &b00000001, &b00000110, &b00000001, &b00011110 ' w Data &b00010001, &b00001010, &b00000100, &b00001010, &b00010001 ' x Data &b00010000, &b00001001, &b00000110, &b00001000, &b00010000 ' y Data &b00010001, &b00010011, &b00010101, &b00011001, &b00010001 ' z Data &b00001000, &b00110110, &b01000001, &b01000001, &b00000000 ' leftcurly Data &b00000000, &b00000000, &b01111111, &b00000000, &b00000000 ' vertline Data &b00000000, &b01000001, &b01000001, &b00110110, &b00001000 ' rightcurly Data &b00000100, &b00001000, &b00001000, &b00001000, &b00010000 ' tilde Data &b01111111, &b01000001, &b01000001, &b01000001, &b01111111 ' del buildDisplayData: scrollcount=0 textpos=0 For k=1 To Len(mytext$) chartext=Asc(Mid$(mytext$,k,1)) chartext=chartext-32 displaydigit0((k-1)*6)=characters(chartext,0) displaydigit0((k-1)*6+1)=characters(chartext,1) displaydigit0((k-1)*6+2)=characters(chartext,2) displaydigit0((k-1)*6+3)=characters(chartext,3) displaydigit0((k-1)*6+4)=characters(chartext,4) If chartext=63 Then displaydigit0((k-1)*6+5)=&b10000000 Else displaydigit0((k-1)*6+5)=0 EndIf scrollcount=scrollcount+6 Next k displaydigit0(scrollcount+0)=0 displaydigit0(scrollcount+1)=0 displaydigit0(scrollcount+2)=0 displaydigit0(scrollcount+3)=0 displaydigit0(scrollcount+4)=0 displaydigit0(scrollcount+5)=0 scrollcount=scrollcount+6 Return I think the junk2 spi command was because I had a 74HC595 chip in the loop as well(not video'd) Video is of version 3.1, whilst code is for v3.2 Regards Dennis Keep plugging away, it is fun learning But can be expensive (if you keep blowing things up). Maximite, ColourMaximite, MM+ |
||||
vk4tec Senior Member Joined: 24/03/2012 Location: AustraliaPosts: 239 |
I have used a futurelec board 8x7 led display . Gps clock display max chip does the digital signal to display control I can send code It is very much down to basic control and timing Andrew vk4tec Andrew Rich VK4TEC www.tech-software.net |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Thanks gents, Andrew, I'd be very interrested to see your circuit and code. Email me direct if you prefer or post here. trevjan@bigpond.com Regards Talbit Talbit |
||||
bigmik Guru Joined: 20/06/2011 Location: AustraliaPosts: 2914 |
Post here for us all to see please!! Pretty Please... Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
vk4tec Senior Member Joined: 24/03/2012 Location: AustraliaPosts: 239 |
The Board I used was a Futerlec 8x7 SEG LED display GPS CLOCK The MAX chip uses SPI. You need to toggle PIN 15 I used the SPI First section sets up the board ( please see MAX / Futurelec board ) http://www.futurlec.com.au/8x7_Segment.jsp Then the digits part sets "12345678" // Rem FUTURELEC 7 segment x 8 LED Rem Andrew Rich Apr 2012 SetPin 16,2 SetPin 17,8 SetPin 18,8 SetPin 15,8 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0A,L) a = SPI(16,17,18,&H02,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0B,L) a = SPI(16,17,18,&H07,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H09,L) a = SPI(16,17,18,&Hff,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0C,L) a = SPI(16,17,18,&H01,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0F,L) a = SPI(16,17,18,&H01,L) Pin(15)=1 Pause 10 Pause 2000 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0F,L) a = SPI(16,17,18,&H00,L) Pin(15)=1 Pause 10 Rem digits Pin(15) =0 Pause 10 a = SPI(16,17,18,&H01,L) a = SPI(16,17,18,&H01,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H02,L) a = SPI(16,17,18,&H02,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H03,L) a = SPI(16,17,18,&H03,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H04,L) a = SPI(16,17,18,&H04,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H05,L) a = SPI(16,17,18,&H05,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H06,L) a = SPI(16,17,18,&H06,L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H07,L) a = SPI(16,17,18,&H07,L) Pin(15)=1 Pause 10 Pause 1000 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H08,L) a = SPI(16,17,18,&H08,L) Pin(15)=1 Pause 10 Andrew Rich VK4TEC www.tech-software.net |
||||
vk4tec Senior Member Joined: 24/03/2012 Location: AustraliaPosts: 239 |
Rem FUTURELEC GPS 7 segment x 8 LED Rem Andrew Rich Apr 2012 max = 20 ' maximum nbr of params Dim arg$(max) ' used to hold the data fields SetPin 16,2 SetPin 17,8 SetPin 18,8 SetPin 15,8 Rem Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0A,L) a = SPI(16,17,18,&H02,L) Pin(15)=1 Pause 10 Rem Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0B,L) a = SPI(16,17,18,&H07,L) Pin(15)=1 Pause 10 Rem Pin(15) =0 Pause 10 a = SPI(16,17,18,&H09,L) a = SPI(16,17,18,&Hff,L) Pin(15)=1 Pause 10 Rem Pin(15) =0 Pause 10 a = SPI(16,17,18,&H0C,L) a = SPI(16,17,18,&H01,L) Pin(15)=1 Pause 10 Rem TEST MODE 'Pin(15) =0 'Pause 10 'a = SPI(16,17,18,&H0F,L) 'a = SPI(16,17,18,&H01,L) 'Pin(15)=1 'Pause 10 'Pause 2000 'Pin(15) =0 'Pause 10 'a = SPI(16,17,18,&H0F,L) 'a = SPI(16,17,18,&H00,L) 'Pin(15)=1 'Pause 10 Open "COM3:19200" As #1 Do nmea_sentence If arg$(0) = "GPRMC" Then Rem GPRMC values Print arg$(1) tme$ = arg$(1) utchr$ = Mid$(arg$(1),1,2) utchr = Val(utchr$) If utchr > 13 Then lclhr = utchr - 14 EndIf If utchr < 14 Then lclhr = utchr + 10 EndIf utcmn$ = Mid$(arg$(1),3,2) utcmn = Val(utcmn$) lclhr$ = Format$(lclhr,"%02g") lclmn$ = Format$(utcmn,"%02g") digit1$ = Mid$(arg$(1),6,1) Pin(15) =0 Pause 10 a = SPI(16,17,18,&H01,L) a = SPI(16,17,18,Val(digit1$),L) Pin(15)=1 Pause 10 digit2$ = Mid$(arg$(1),5,1) Pin(15) =0 Pause 10 a = SPI(16,17,18,&H02,L) a = SPI(16,17,18,Val(digit2$),L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H03,L) a = SPI(16,17,18,10,L) Pin(15)=1 Pause 10 digit3$ = Mid$(arg$(1),4,1) Pin(15) =0 Pause 10 a = SPI(16,17,18,&H04,L) a = SPI(16,17,18,Val(digit3$),L) Pin(15)=1 Pause 10 digit4$ = Mid$(arg$(1),3,1) Pin(15) =0 Pause 10 a = SPI(16,17,18,&H05,L) a = SPI(16,17,18,Val(digit4$),L) Pin(15)=1 Pause 10 Pin(15) =0 Pause 10 a = SPI(16,17,18,&H06,L) a = SPI(16,17,18,10,L) Pin(15)=1 Pause 10 digit5$ = Mid$(lclhr$,2,1) Pin(15) =0 Pause 10 a = SPI(16,17,18,&H07,L) a = SPI(16,17,18,Val(digit5$),L) Pin(15)=1 Pause 10 digit6$ = Mid$(lclhr$,1,1) Pin(15) =0 Pause 10 a = SPI(16,17,18,&H08,L) a = SPI(16,17,18,Val(digit6$),L) Pin(15)=1 Pause 10 EndIf Loop Rem -- SUBS -- Sub nmea_sentence Do msg$ ="$" ' subroutine start Do While Input$(1, #1) <> "$" : Loop ' wait for the start For i = 0 To max arg$(i) = "" ' clear ready for data Do ' loops until a specific exit x$ = Input$(1, #1) msg$ = msg$ + x$ ' get the character If x$ = "," Then Exit ' new data field, increment i If x$ = "*" Then Return ' we have all the data so return arg$(i) = arg$(i) + x$ 'Print arg$(i) ' add to the data Loop 'Print arg$(i) ' loop back for the next char Next i ' move to the next data field ' Print "Corrupt data..." ' exceeded max data items 'Print msg$ Loop End Sub Andrew Rich VK4TEC www.tech-software.net |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Thanks Andrew, Fantastic! I'm getting lazy in my old age. I can certainly make use of your efforts. Talbit Talbit |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Andrew, That looks like a great board. I've ordered one already. Sensible price too. Can you tell how long it takes to update the display? I see you've been doing a lot of GPS work. Talbit. Talbit |
||||
Print this page |