It should. I believe it just uses goto's, no stack use.
yes the 20 if then work, no problem. Assembling took maybe 3 times longer then those blinky codes and it uses nearly 3/5 of the code space in my 16F628..but works flawlessly.
to Joe:
oh man I tried to use DTs bargraph routines but only got the error "coulndīt open bargraph.bas" or something. Copied it in a "dozen" directories around the main PBP main and my project directories...didnīt work, always the same error.
But I uses DTs instant interrupt blinky program and that worked....so I donīt know a bone about how to work around "include" problems.
On the other my bargraph is quite crude with its big bars....but a fine bargraph isnīt an option here...way to hard to see while driving the car or bike, you need only sort of lean/rich tendencies and the lambda sensor it VERY jumpy around the stochiometric area.
8 leds would do but I did it mainly because of 3 reasons:
1.: I COULD do it.......with a little help of my friends....greetings to you all!
2.: One of my employees is sort of colour blind and wanted something to recocnize
without colours.
3.: we do a lot around sportscars engines and we test drive them mainly when the sun shines and a LED bargraph is hard to read while driving 100km/h in corners and the sun shining all over....
Yeah......Iīm telling junk. Here in Germany the sunīs just a rumour you know, seen last time in june 2007 or so....
Last edited by Mugelpower; - 3rd March 2008 at 07:13.
Here it is
982 words
Code:<font color="#008000">@__config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF </font><font color="#000080"><b>INCLUDE </b></font><font color="#008000"><b>"modedefs.bas" </b></font><font color="#000080"><b>DEFINE </b></font>OSC <font color="#FF0000"><b>4 </b></font>Uin <font color="#000080"><b>VAR WORD </b></font>B0 <font color="#000080"><b>VAR WORD </b><i>' Cnt is a word variable </i></font>InputData <font color="#000080"><b>VAR WORD </b><i>' variable to receive data into </i></font>RepNo <font color="#000080"><b>VAR BYTE </b><i>' START OF MAIN PROGRAM ' </i></font>CMCON = <font color="#FF0000"><b>7 </b></font><font color="#000080"><i>' RA0-RA3 are digital I/O </i></font>TRISA = <font color="#FF0000"><b>0 </b></font><font color="#000080"><i>' PORT A is output </i></font>TRISB = <font color="#FF0000"><b>1 </b></font><font color="#000080"><i>' RB0 is Input others output </i></font>Main: <font color="#000080"><b>SERIN </b></font>PORTB.<font color="#FF0000"><b>0</b></font>,N2400,B0 B0 = <font color="#FF0000"><b>100 </b></font>* B0 Uin = B0 / <font color="#FF0000"><b>207 </b></font><font color="#000080"><b>GOSUB </b></font>Bargraph <font color="#000080"><b>PAUSE </b></font><font color="#FF0000"><b>5 </b></font><font color="#000080"><b>GOTO </b></font>Main Bargraph: <font color="#000080"><b>LCDOUT </b></font><font color="#FF0000"><b>$fe</b></font>,<font color="#FF0000"><b>1 </b></font><font color="#000080"><i>'Valid for all cases. </i><b>SELECT CASE </b></font>Uin <font color="#000080"><b>CASE IS </b></font>< <font color="#FF0000"><b>10 </b></font><font color="#000080"><b>LCDOUT </b></font><font color="#008000"><b>"TOO LOW" </b></font><font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>10 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>15 </b></font>RepNo = <font color="#FF0000"><b>1 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>15 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>19 </b></font>RepNo = <font color="#FF0000"><b>2 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>19 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>24 </b></font>RepNo = <font color="#FF0000"><b>3 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>24 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>29 </b></font>RepNo = <font color="#FF0000"><b>4 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>29 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>34 </b></font>RepNo = <font color="#FF0000"><b>5 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>34 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>43 </b></font>RepNo = <font color="#FF0000"><b>6 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>43 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>53 </b></font>RepNo = <font color="#FF0000"><b>7 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>53 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>62 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>62 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>72 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>1 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>72 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>81 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>2 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>81 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>86 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>3 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>86 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>91 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>4 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>91 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>96 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>5 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>96 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>100 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>6 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>100 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>105 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>7 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE IS </b></font>> <font color="#FF0000"><b>105 </b></font><font color="#000080"><b>AND IS </b></font><= <font color="#FF0000"><b>110 </b></font>RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>GOSUB </b></font>LCD2 RepNo = <font color="#FF0000"><b>8 </b></font><font color="#000080"><b>GOSUB </b></font>RepLCD <font color="#000080"><b>CASE ELSE LCDOUT </b></font><font color="#FF0000"><b>$FE</b></font>,<font color="#FF0000"><b>$C0</b></font>,<font color="#008000"><b>"TOO RICH" </b></font><font color="#000080"><b>END SELECT RETURN </b></font>RepLCD: <font color="#000080"><b>WHILE </b></font>RepNo > <font color="#FF0000"><b>0 </b></font><font color="#000080"><b>LCDOUT </b></font><font color="#FF0000"><b>255 </b></font>RepNo = RepNo - <font color="#FF0000"><b>1 </b></font><font color="#000080"><b>WEND </b></font><font color="#000080"><b>RETURN </b></font>LCD2: <font color="#000080"><b>LCDOUT </b></font><font color="#FF0000"><b>$FE</b></font>,<font color="#FF0000"><b>$C0 </b></font><font color="#000080"><b>RETURN </b></font>
Btw:
Select case produces 100 words more!
So, if you go with your IF..THENs, it will be approx. 882 words, but select case provides a clean look.
Last edited by sayzer; - 3rd March 2008 at 16:11.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Another way
Code:'************************************************* **************** '* Name : Analogbargraph1(16F628A).BAS * '* Author : M.David * '* Notice : Copyright (c) 2008 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 28.02.2008 * '* Version : 1.0 * '* Notes : needs 12F675 for Lambdatesting device and LCD 1X16 * '* : input 0.1 - 1.1 Volts in GPIO.0 * '* : needs ADCserout(12F675).bas * ' 569 Lines '************************************************* **************** ' ' DEFINITIONS @ __config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF Include "modedefs.bas" 'CMCON=%00000111 DEFINE OSC 4 NbPatterns var Byte Uin var word B0 VAR word ' Cnt is a word variable inputData var word ' variable to receive data into ' START OF MAIN PROGRAM ' CMCON = 7 ' RA0-RA3 are digital I/O TRISA = 0 ' PORT A is output TRISB = 1 ' RB0 is Input others output main: Serin PORTB.0,N2400,B0 B0 = 100 * B0 Uin = B0 / 207 bargraph: IF Uin < 10 THEN LCDOUT $FE,1,"TOO LOW" : GOTO Show IF Uin > 110 THEN LCDOUT $FE,1,"TOO HIGH" : GOTO Show LOOKDOWN2 Uin , < [ 11,16,20,25,30,35,44,54,63], NbPatterns LCDOUT $FE, 1, REP 255\ NbPatterns IF Uin > 62 THEN LOOKDOWN2 Uin , < [ 63,73,82,87,92,97,101,106,111], NbPatterns LCDOUT $FE, 1, REP 255\ 8 LCDOUT $FE, $C0, REP 255\ NbPatterns ENDIF Show: Pause 5 goto main END ' End of program
569 Words ...
Alain
Last edited by Acetronics2; - 3rd March 2008 at 09:51. Reason: CMCON : Double definition ....
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hey Girls & Guys,
seems I poked into a bees nest.... I will try those codes in the evening (10 hrs from now).
Youre really helpful.
How about a code for extern interrupt that triggers a 1 ms high port after a delay found in a lookdown/case/if then row list? from 3 to 600 Hz of course......to get a constant phase shift between trigger and output.....
Its oughta be real fast!! 20MHz 16F628A preferred
"On interrupt" gets 180° phase shift (maximum limit) at 200 Hz.....
I dunno how to integrate a variable delay into DTs instant interrupts....
Could you explain that better ???
You're asking for a PBP written electronic ignition here ...
don't you think you abuse ... just a little bit !!!
Have an eye here ... : http://a110.free.fr/SPIP172a110/arti...?id_article=23
Ok, assembler ... but kit or scratch realizable, and the forum offers a Huge help ...
Alain
PS: I'm working on a full PBP version ... but Assembler interrupts can't be avoided !!!
Last edited by Acetronics2; - 3rd March 2008 at 09:39.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi Acetronics,
yeah, in Principle thats that. BUT: thats french (ARGL-GARG!!) and I donīt understand 2% of it.
And: I have to modify the code it myself fromtime to time which could only be done if Iīm knowing quite a lot about the code. Man, thats a BIG FISH to swallow for an oldschool mechanic. Learning programming, trying to avoid asm, learning that asm couldnīt be avoided...... ARGL-GARG !
13 LINES!Code:@ __config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF Include "modedefs.bas" nbpatterns var byte:uin var word:cmcon=7:trisa=0:trisb=1 main: serin portb.0,n2400,uin:uin=(uin*100)/207:lcdout $fe,1,"TOO ":if uin<10 then lcdout "LOW":goto show IF Uin > 110 THEN LCDOUT "HIGH": GOTO Show lookdown2 uin,<[11,16,20,25,30,35,44,54,63],nbpatterns:lcdout $fe,1,rep 255\nbpatterns if uin > 62 then lookdown2 uin,<[ 63,73,82,87,92,97,101,106,111], NbPatterns lcdout $fe,1,rep 255\ 8,$fe, $c0, rep 255\ nbpatterns ENDIF Show: Pause 5:goto main END ' End of program![]()
Last edited by skimask; - 3rd March 2008 at 16:29.
Hi Skimask,
yeah will try that too, never worked around the lookdown commands...will see how it works
sincerely
Mugel
Last edited by Acetronics2; - 3rd March 2008 at 15:46.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Bookmarks