Thanks Darrel. It gives me an amazing look for my project. Can you tell me if I use 2x16 Alpha LCD. How many bars that I can get per line?
Thanks Darrel. It gives me an amazing look for my project. Can you tell me if I use 2x16 Alpha LCD. How many bars that I can get per line?
Hi vbcoder,
You're welcome.
There are 3 bars per character, so you can get 48 per line on a 2x16.
<br>
DT
gerçekten güzel uygulama teşekkür ediyorum.
[email protected]
TÜRKİYE
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Me neither!
But I did catch the "Thank" part.
So in case that's what it was...
You're welcome zaferakbay.
Hope you get good use out of it.
<br>
DT
Ok let's try in split words..
gerçekten = Actually, honestly,indeed, literrally, positively,properly,really,simply, truly
güzel = attractive beautiful, bonny, bracing, cherub,comely,dreamy,elegant,enjoyable,fair,fine,g allant,glorious,graceful,grand,handsome,lovely,nic e...
uygulama = application, execution,implementation,practice
teşekkür = *** can't be found *****
ediyorum = *** can't be found ****
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
hmmm,
positively glorious application
properly elegant implementation
honestly beautiful execution
really dreamy practice
Hey, works for me
As long as those last 2 words aren't
Stink, Pile or S___
<br>
DT
Not quite “teşekkür ediyorum”
teşekkür ederim = thank you
http://cali.arizona.edu/maxnet/tur/nalan1/foo00005.htm
WordReference.com Language Forums
"Teşekkür ederim" (= I thank you) is still widely used in Turkey
http://forum.wordreference.com/showthread.php?t=252655
Language Forums, maybe we could post PICBasic in their forum and they could come looking for us!
Ohm it's not just a good idea... it's the LAW !
Great. Thanks P.U.
Now that we know what he said, I can give a better reply ...
zaferakbay,
Rica ederim.
(You're Welcome)
<br>
DT
Hi, Darrel
I know it's YOUR Bargraph example ... but 5 bars can be used with "general programming" ...
May be a Typo from yours ???
Translated and modified from a Stamp application :
' This program generates a horizontal bargraph
' with a 2x16 Intelligent LCD Display HD 44780 / KS 0062.
DEFINE OSC 20
DEFINE LCD_EBIT 1
Led var Portb.5
Scale var Portb.2
' ** Variables **
BarVal Var Word ' Value to be graphed.
Bars Var Byte ' Number of full |||/||||| bars to draw.
Balance Var Byte ' Balance left after all |||/|||||s are drawn.
Padding Var Byte ' Number of spaces to fill width.
Balf Var Byte ' Is a 'Balance' character needed? (1=yes, 0=no).
Temp Var Byte
Fullbar Var Byte
Maxbar Var Byte
' ** Constants **
BWdth Con 16
Basebar Con 0 ' ASCII value of 0 bar (blank).
IF NOT Scale THEN
Fullbar = 3
ELSE
Fullbar = 5
ENDIF
Maxbar = BWdth*Fullbar ' Max bar counts.
' Transfer the bit patterns that make up the bars into the LCD's CGRAM.
' The vertical bars are made up of 8 identical bit patterns
' A | bar consists of 0, 5 times $10, 0
' A || bar consists of 0, 5 times $14, 0
' A ||| bar consists of 0, 5 times $15, 0
' We repeat each pattern 8 times.
IF Fullbar = 3 THEN
Lcdout $FE,64,0,0,0,0,0,0,0,0 'Motif 0
Lcdout $0,$10,$10,$10,$10,$10,$10,$0 'Motif 1
Lcdout $0,$14,$14,$14,$14,$14,$14,$0 'Motif 2
Lcdout $0,$15,$15,$15,$15,$15,$15,$0 'Motif 3
ELSE
Lcdout $FE,64,0,0,0,0,0,0,0,0 'Motif 0
Lcdout $0,$10,$10,$10,$10,$10,$10,$0 'Motif 1
Lcdout $0,$18,$18,$18,$18,$18,$18,$0 'Motif 2
Lcdout $0,$1C,$1C,$1C,$1C,$1C,$1C,$0 'Motif 3
Lcdout $0,$1E,$1E,$1E,$1E,$1E,$1E,$0 'Motif 4
Lcdout $0,$1F,$1F,$1F,$1F,$1F,$1F,$0 'Motif 5
ENDIF
Goto OverBargraph
' The value in 'Bar_Val' is displayed as a horizontal bar graph
' from the current cursor location with a total width (in characters) set by the WIDTH constant.
' Each character position can represent a maximum value of 3/5 using the Fullbar character |||.
' The routine calculates how many full bars to use by dividing by 3/5.
' If there is a remainder after dividing by 3/5, the routine joins on a partial-bar character
' ( | or || or ||| or |||| or ||||| ) to represent the balance.
' Then it pads out the remainder of the bar width with spaces to erase any leftover bars
Bargraph:
Bars = (BarVal min MaxBar) / Fullbar ' One full bar for each 3/5 graph units.
Balance = (BarVal min Maxbar) //Fullbar ' Balance is the remainder after a division by 3/5.
Balf = Balance min 1
Padding = BWdth - (Bars + Balf) ' Number of spaces to fill bar width.
LCDOut Rep Fullbar\Bars,Rep (Balance + Basebar)\Balf,Rep " " \Padding
Return
OverBargraph:
For BarVal = 0 to Maxbar
Lcdout $FE,$80
Gosub Bargraph
Lcdout $FE, $C0, #BarVal," "
Pause 300
Next BarVal
Alain
************************************************** ***********************
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 " !!!
*****************************************
By the way, talking about the great piece of code. I am trying to make it work on a logarithmic scale, to measure audio levels from -40 to +6dbm (-40db=20mV, 0db=0,775V rms at 600 ohm and +6db=2V). As it can be seen it is a very large dynamic region.
For a few steps it's OK to do it with a lookdown, but if the display is 20 characters wide and with 3 bars each, total 60 steps, a table is slow. So a computational method is to be found.
Testing the suggestions of Tracy Allens at www.emesys.com. I do not fully understand what he is doing there though.
Any other ideas welcome.
Ioannis
Last edited by Ioannis; - 21st June 2007 at 09:09.
Hi Alain,
Cool, more examples.
I tried using all 5 bars when I wrote it, but was never happy with the results. There seemed to be pauses, jumping or something missing (depending on which way I tried to do it). All due to those darn spaces between the characters. Had the same problem trying Vertical Bars.
But I'll fire up your example and see if it looks any better.
If it works better, I'm going to hate myself for losing to a Basic Stamp program.
<br>
DT
Hi, Ioannis
I just wrote a 255 values lookup table ( convert a LOG pot to lin response ) ...
for Malc-c electric train control.
did not take more than 3 minutes to load it ...
I use a small old Casio FX-880P personnal Computer ... programmed in BASIC ... WOW !!!
You also can use a GWBasic little program on your computer ( on the W98 CD Goldies ...)
Other solution is to create an Excel application writing in a window the LOOKUP values, separated by their commas ... and just paste it into the editor.
like this one :
http://www.electronic-engineering.ch...generator.html
The third solution is to create a "Lookup file" with Excel ... and INCLUDE it at the place pointed at by PbP ...
You'll discover here PbP really wastes a lot of room ... ( no, no ...Darrel, not on the head ... )
much,much better ( and really simple ) to write it in assembler !!! ( if you need an ASM example ... no Pb !!! )
Regards
Alain
************************************************** ***********************
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 " !!!
*****************************************
Ioannis,
Interesting problem.
I looked at the emesys site, and the idea of using NCD/DCD for the log function is really interesting (and I think, workable).
I'll see what me and Excel can come up with. (might take a few days, so don't wait if you're in a hurry).
Are those voltages what the PIC is seeing? -40db = 20mv etc.
Or is that before an RMS-DC conversion?
And if not, what does the PIC see?
<br>
DT
Hmm, a log pot to table? Interesting idea!
I have such a Casio too (the PB-410 model). It helped a lot in the past!
Thanks Darrel. No, I am not in a hurry. I am trying to make it as fast as possible in response. The program is doing other things too so cannot affort delays in tables to choose one of 60.
Yes the NCD/DCD is clever idea. Trying to comprehand...
The 0db as seen on most old cassete recorder is the standard audio level of 1mW at 600ohm. That is about 0,775V rms. If a real VU-meter is checked, the dynamic range is more than 40db. On good ones, it extends even more. So, a log scaling has to be utilized, in order to make good use of the LCDBargraph. Just ADC and displaying makes for nearly 16-19db range!
The -40db is 7.75mV rms or 22mVp-p. These voltages have to scaled and converted with rms converter or active rectifier. Max range would be +6dbm. That is 1.55Vrms or 4.36Vp-p.
I intend to scale the 1.55Vrms to 4Vdc max (or somthing near) for the PIC to be happy.
Ioannis
Ouch.I am trying to make it as fast as possible in response. The program is doing other things too so cannot affort delays in tables to choose one of 60.
I think tying to calculate it is going to take a lot longer than a Table Lookup. (I do mean A LOT)
Maybe Alain's way might be better.
Up to you, if you want to try.
<br>
DT
Hi, Ioannis
Nothing Quicker than a lookup table ... ( PbP lookup not slower than ASM ... cause it's written quite the same !!! )
That's the way used for automobile ignitions ... where we count the µs ...
Alain
************************************************** ***********************
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 " !!!
*****************************************
Thanks. I will see which way I am going to choose. After all precision is not important when displaying audio levels, isn't it? So a table might be better.
Ioannis
Edit: That post was meant as an answer to Darrel, but it came 1 min after yours Alain. But it fit both! Mysterious ways this forum works!
Last edited by Ioannis; - 21st June 2007 at 11:07.
Sorry, just another Shameless Plug.
Here's a way you might be able to implement the Lookup Table.
http://www.picbasic.co.uk/forum/show...php?t=3891#LAB
Quietly blushing,
DT
Hmm, thats very clever. I think is faster too!
Hands on experiment!
Thanks Darrel.
Ioannis
Hi, Ioannis
this will be smaller ... but not faster. ( operations are still the same ...)
Smaller ??? not sure ... still need 14 bits per value ...
BUT ...
as only 6 bits used per value, could try Value.Highbyte and Value.lowbyte to place 2 values in 1 location ...
just an idea ... but really fun a table loading !!!
mmmm, stupid idea: if you have 60 ( ? ) free locations in the RAM ( You did not tell us about the processor ...), you could download from the EEPROM to the RAM at each power-up ... and use a "simple" 60 values Array.
no faster way !!!
If you want to get a bit more precision ... you can linearize between two points ( "ax+b" line ) doesn't use much CPU ...
that will be "less false" ... LOL
Alain
************************************************** ***********************
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 " !!!
*****************************************
mmm, kinda mix with embedded strings in your code space and lookup table...
So the Excel sheet would have to pack it in 14Bit and later you use DA.
How's that sound? pretty bad to me as the unpacking method will certainely be slightly longer to execute than reading a single Byte for a DT, DW table ...
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi, Steve
Yess ... the packing method could work great if we had a 1 value to 1 Value "translation"
I think the problem is a bit more complicated than we think at first ...
we have to convert a 256 values log scale ( I do not want to think to 10 bits !!! ) to a 60 values lin scale ...
so, many input values have the same output result ...
Much,much room left !!!
What's the ADC resolution needed if we want a 1 dB precision output, even @ - 40 dB ???
Much,much,much,much,much,much room left !!! ... 255 values limit fully exploded !!!
Could we think to a BIG Select Case statement with 59 times " Case is < $xx or $xxxx" ... I do not know about the CPU time used ...
but it seems a lot easier to write and calculate.
Alain
************************************************** ***********************
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 " !!!
*****************************************
I've been playing with the NCD/DCD with excel, and there's something I can't seem to work in there.
Granted, I'm relying on 30 year old memories from when I was working on microwave radios in the air force. But if memory serves me right, then a change of 3 db is double the power, and -3 db is half the power. And since the impedance is constant, it also means the voltage is either doubled or halved.
So let's assume the signal is scaled so that the (maximum A/D reading +1) corresponds to +7 dbm. Then half of that would be 512 or +4 dbm.
If you keep dividing that down, since there's only 10 bit's, you end up with a minimum of -23 dbm with an A/D input of 1.
And it appears that it would take a resolution of 16-bits to be able to get down to -40 dbm.
I think this applies to however you do it. Lookup, calculate, ...
ADDED: And any noise or offset voltages will Obliterate the low end.
But then, maybe I've got it all wrong? ??
<br>
Last edited by Darrel Taylor; - 22nd June 2007 at 04:51. Reason: Obliteration.
DT
Hi, Darrel
Looks you're perfectly right ... the PIC ADC does not have the 60 dB dynamics(? ... I meant range !!!) our friend Ioannis looks for.
IF you were involved in radios ... may be the ref. "CA3089" will remind you some Vu-meter designs ... ( Use of pin 13 ...)
So, If we used such a Log amplifier to translate from Log to lin scale ... we could easily get this 60 dB Scale ... may be more !!!
Of course ... the drawing is in my Dataroom ... and I still must have a PCB somewhere !!! ( Was a very old Elektor application for an Audio Level-meter ( Sonometer) ... as the CA3089 can work with audio frequencies ... )
Read you soon
Alain
PS: found another with a NE604 Chip ...70 dB covered !!! ... heeuuuuuu file weights ... 325 kB DAMNED !!!
Hi, Savnik
+ 3 dB means the double ... for whatever you want.
but + 6 dB for Power means +3 dB for corresponding voltage
Last edited by Acetronics2; - 22nd June 2007 at 08:23.
************************************************** ***********************
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 " !!!
*****************************************
Thanks Alain for the ideas. I suppose one has to do it in practice and check the response of the circuit.
The PIC is not yet defined. I will choose one after we will end with the spec's (memory needed etc).
Steve, I agree that I have to pay for the extraction in terms of speed. But then, I guess, somewhere in the program there will be a point needing mcu power as it seems.
Now, Darrel, as Nikos (Savnik) stated, 3db is indeed a double or half the power. But as for voltage, you need 6db.
db(Watts)=10*LOG*(P1/P2)
db(Volts)=20*LOG*(V1/V2)
For the case we discuss, replace the V2 with 0.775Volts or the P2 with 1mW.
If you make the maths you can prove it.
Relative to the dynamic range, well I have to measure from 7.75mV up to 1.55 RMS or from 11mVpk up to 2.19Vpk. Lets make it easier and the MAX be 2Vpk.
I will Scale it to max 5Volt (x2.5), so the minimum will be 11mV*2.5=27.5mV.
For a 10-bit ADC the LSB will be 4.88mV, so a 10-bit ADC will be enough for a 46db dynamic range. If I am wrong please correct me.
Now, about the CA3089 or the better one that I used long ago, CA3189. Where does this chip fit here?
A big thank you to all responded.
Ioannis
P.S. The idea of Select Case may also be a nice alternative since for every BAR in the Bargraph there are alo of values to fit. It will be a long Select case of course... I have to try it.
************************************************** ***********************
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, Ioannis
could you PM me a mail adress for sending the scheme... ( and explanations of the NE 604 use ... if you can read French ( sorry ...))
Alain
************************************************** ***********************
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 " !!!
*****************************************
Alain,
Finally got a chance to run your bargraph. (it works)
But I'm still not crazy about the 5-bars. Here's what it looks like
<script type="text/javascript"src="http://www.pbpgroup.com/DT_INTS-14/V-LCD_Disp.js"></script>
<script type="text/javascript"src="http://www.pbpgroup.com/js/AceBargraph.js"></script>
It's not as noticable when it moves fast, but that jump is still there.
And while it compiles to about 100 words less than mine, it doesn't have all those features like placing it anywhere on the screen, making it any width of characters, scaling the input values to any range up to 32768, multiple bars on the screen and 3 different styles.
But it definately does a 1-line 3/5-bar graph.
DT
Well, I tested NE604 and was amazed at Audio freqs. A nearly 65dB range was obtainable on a breadborad! Incredible! So the LCD_Bargraph has now a friend for audio signals making great VU-meter. One catch is that NE604 is expensive one. Here about 10 Euros in small qts. Thanks Alain for the tip.
C/O Darrel:
While trying to develop my project using your interrupts, I stuck on, I think for sure, stupid one. The attached sample code does not respond to PORTB.0 interrupt. Is there any mistake I 've made and can't see?
Ioannis
Last edited by Ioannis; - 24th June 2007 at 19:03.
Hi, Darrel
Yes, ... I know the big problem at "high speed" is unequal calculating times upon the place pointed at ...
but we must remember it's not a GLCD ... "some holes in the somewhere" ...
Your picture's really nice !!! ...
By the way ... I have a beautiful 122x32 GLCD here ... hmmmmmm, I might give a look to that !!!
read you soon
Alain
Last edited by Acetronics2; - 24th June 2007 at 20:07.
************************************************** ***********************
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 " !!!
*****************************************
I've got some 'pre-fab' code for the 122x32 types. Nothing wild, just the basic setup/configure routines, some basic 'x,y' plotting, and some text output routines. But it works great for me...
EDIT: I just started a new thread with the code described above attached. Again, nothing fancy, but I've been using the same block of code for a couple of years now...
Last edited by skimask; - 24th June 2007 at 22:29. Reason: EDIT: added thread notice
Thanks Darrel, but it really doesn't matter since there is a real resistor for Pull-up on the pcb (Picdem2+).
I have not found why is not responding...
Ioannis
Ioannis,
I can't see any other problems with the program. Or, any reason why it wouldn't work with the PICDEM2+.
Which PIC are you using with the PICDEM?
<br>
DT
Currently the 16F877. I have handy also other to try. Maybe a 18F452.
To be sure that Portb.0 is OK, I tested with a simple loop of the kind:
while portb.0=1
wend
high LED1
and worked OK. So electrically there is no problem.
PICDEM2+ is connected to ICD2 working in programmer mode only. So, there is for sure no other source of interference.
Skimask: could you post the link you mentioned? Thanks
Ioannis
Last edited by Ioannis; - 26th June 2007 at 06:57.
Hi, Ioannis
There : http://www.picbasic.co.uk/forum/showthread.php?t=6574
<< While trying to develop my project using your interrupts, I stuck on, I think for sure, stupid one. The attached sample code does not respond to PORTB.0 interrupt. Is there any mistake I 've made and can't see? >>
Thanks to PbP ... TRISB = 255 and led on PORTB.2 will work ...
BUT does your PORTB.0 change state when button ( ?) pushed ... in other words, is the pullup or pulldown resistor the OTHER side of the Pushbutton ... ( yes, I know it's a really stupid mistake ...but ...)
have a nice day
Alain
Last edited by Acetronics2; - 26th June 2007 at 10:13.
************************************************** ***********************
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 " !!!
*****************************************
Thanks Alain for the link.
About the portb I did not really understood what you meant.
I test the portb.0 independently from the Interrupts and when pressed the program really see it. Like that:
while portb.0=1
wend
high led1
If button on Portb.0 is NOT pressed the program loops in the While-wend. If pressed then the LED1 lights, showing that there is no problem in the Setup or connections.
But when trying the Interrupts nothing happens. Really annoying...
Ioannis
Bookmarks