Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:54 29 Nov 2024 Privacy Policy
Jump to

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 : Micromite beta 7

     Page 5 of 7    
Author Message
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 10:58am 25 Feb 2014
Copy link to clipboard 
Print this post

  BobD said  ...
How practical is this? Thoughts anyone.


There is no thought, is how it must be. You can issue the measure command to have a read, then, you can read the sensor much later, no obligation. If I remember right, for the DS18B20 it was a minimum of ~750ms at 12bit resolution (which I prefer it anytime)...

____
Edit: And I just had a thought. What if the interrupts were the reason Geoff chose the smallest resolution for the Dallas sensor considering that for the lower resolution there is a lower waiting time? If he split it into the two commands, then we kindly request the 12bit resolution. Edited by vasi 2014-02-26
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3196
Posted: 01:42pm 25 Feb 2014
Copy link to clipboard 
Print this post

I chose the 0.25 degree resolution because the sensor only has an accuracy of 0.5 degrees and that needed a conversion time to 200mS which was reasonable. There is not a lot of point in selecting a higher resolution because the thing is not accurate enough to make the reading meaningful and it takes forever to make that measurement.

If you want to use the highest resolution possible and split the conversion and the reading into two parts you could use the following (this is a modified version of the code posted earlier by jman):

Sub StartMeasure (PinNbr)
OneWire Reset PinNbr ' reset
OneWire Write PinNbr, 2, 5, &HCC, &H4E, &H00, &H00, &H7F
OneWire Write PinNbr, 1, 2, &HCC, &H44
End Sub

Function GetReading(PinNbr)
Local TH, TL
OneWire Write PinNbr, 1, 2, &HCC, &HBE
OneWire Read PinNbr, 2, 2, TL, TH
GetReading= ((TH And &b111) * 256 + TL) / 16
If T2 And &b1000 Then GetReading= -GetReading' adjust if negative
End Function

You call StartMeasure first and then your program can do whatever it wants. Then, after a second or more has elapsed, use GetReading to get the temperature at the full resolution of the sensor.

Easy!

Geoff
Geoff Graham - http://geoffg.net
 
jman

Guru

Joined: 12/06/2011
Location: New Zealand
Posts: 711
Posted: 02:18pm 25 Feb 2014
Copy link to clipboard 
Print this post

Great Geoff

This is a cool method and shall be added to my MMBasic utils folder

Regards
Jman


 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 05:07pm 25 Feb 2014
Copy link to clipboard 
Print this post

Another confirmation that the beta7 LCD routine works well on a 4 line display. This time using the white-on-blue J204A module that was $9 on DX.com last year. It looks pretty good.



From the info I've managed to glean, this display uses the SPLC780 controller, which Geoff could add to the KS0066 & HD44780 compatibles he's quoted in the Manual.

One hassle with the 'datasheet' given for the module was that the 'standard' 16 pin connection shows DB0-DB3 as the 'data' bits and DB4-DB7 as not connected. This is the reverse of Geoff's diagram on page 18 of the MicroMite manual and Geoff's version is correct.

GregEdited by paceman 2014-02-27
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 06:14pm 25 Feb 2014
Copy link to clipboard 
Print this post

Geoff,
there were a few points that caught me out when I was getting the 20x4 LCD module going and I think would be worth including in the Manual.

1. Firstly the comment I made in the post above about the reversed DB0-DB7 documentation shown for a lot of modules from the cheaper suppliers, i.e. eBay and DX.com.

2. Secondly, the pin3 'contrast' connnection needs some clarification (and it's also pretty unclear on other datasheets). I originally assumed it worked the same as the backlight, i.e. needing a +ve and -ve supply as shown in the Manual's page 18 diagram. I duly connected pin 3 of the module's 'standard' 16-pin connector to the wiper of the 10K pot and the other ends of the pot to 5v & Gnd. After several hours of head scratching it turned out that (for this module at least) there should be no connection to the positive supply! If it is connected, lines 1&3 (only) of the display show up against the backlighting, but no data is displayed.

3. I've yet to see a datasheet mention that the contrast adjustment pot needs to be set before data can be displayed. I assumed that there would be some, or too much, contrast shown before the pot was set, but in fact nothing showed at all at my original mid-point setting. This makes life very frustrating when issues 1&2 above are compounding things. The point needs making that the contrast pot should be adjusted until the outline of the character positions can be seen against the backlighting and then that position should allow displayed characters to be seen.

Greg

Edit - this Arduino tutorial Arduino LCD tutorial describes the pin3 connection better - also note the asterixed point below the table.
Edited by paceman 2014-02-27
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 11:29pm 25 Feb 2014
Copy link to clipboard 
Print this post

This is probably a dumb question but how do I use the 'OPTION AUTORUN ON'command.
I've searched the manual and can't find anything.
Paul.
"It is better to be ignorant and ask a stupid question than to be plain Stupid and not ask at all"
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:21am 26 Feb 2014
Copy link to clipboard 
Print this post

Hi Geoff,
I'm working on a uMite timer (for a UV exposure box) using the previously mentioned 20x4 LCD display. Is it possible to modify the LCD writing command to allow a flashing cursor to be placed at a given location?

Greg
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 04:33am 26 Feb 2014
Copy link to clipboard 
Print this post

Hi palcal

Simply type 'OPTION AUTORUN ON' and then when you reboot; or re-apply power to the uMite it will automatically run the program saved in memory.

ctrl-C to abort program in usual manner.

'OPTION AUTORUN OFF' to stop this auto-run feature (as will typing 'NEW'.

Brief snippet at top of Page 40 in Beta 7 manual.


Hope this helps you out . . .

Regards,

Phil
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 04:44am 26 Feb 2014
Copy link to clipboard 
Print this post

Hi Greg,

Regarding the 'Flashing Cursor', there is no real concept of a current cursor position since you are totally in control of what is displayed, and where it is displayed, on the LCD.

Geoff has simply given the user the ability to write data/messages to the LCD referenced by Line No & Char position.

So if you need a cursor then since you are in control of what is currently on the screen then you should know the LineNo & CharPosition of where you would like such a cursor. So simply use the SetTick command to call a 'ToggleCursor' sub that toggles the required cursor character at the current cursor position. The timing you set in the SetTick command will determine the cursor 'flash' rate.


I hope this makes sense

Regards,
Phil
For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 10:57am 26 Feb 2014
Copy link to clipboard 
Print this post

An LCD has a cursor.
You can choose between a underline code = 0xOE
or a blinking-block code = 0x0F

You can make the cursor invisible with code = 0x12

The normal entry mode code = 0x06. This will put the cursor behind the last character.

Microblocks. Build with logic.
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 12:41pm 26 Feb 2014
Copy link to clipboard 
Print this post

Look up the data sheet for the LCD driver and you will find all sorts of things you can do with the screen with respect to screen shift direction, cursor control etc. It is a bit nebulous but a bit of experimenting can't do any harm. I am half way through compiling a list of command bytes and will post it when complete. I am doing it for the 16x2 but it will be much the same for the 20x4
David M.
 
palcal

Guru

Joined: 12/10/2011
Location: Australia
Posts: 1873
Posted: 12:41pm 26 Feb 2014
Copy link to clipboard 
Print this post

Thanks WhiteWizzard
Paul.
"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: Australia
Posts: 3196
Posted: 01:59pm 26 Feb 2014
Copy link to clipboard 
Print this post

Yes, there are many special things that you can do with an LCD including custom character sets, cursors, etc. These vary between LCD driver chips and the Micromite LCD command just implements the basic display data function that should work across all LCDs.

My answer to all instances of this type of query is that you will have to drive the display directly to do special function that are available on your display.

MOBI's effort sounds great and should help a lot in this regard.

Geoff
Geoff Graham - http://geoffg.net
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 03:34pm 26 Feb 2014
Copy link to clipboard 
Print this post

  Geoff said  Yes, there are many special things that you can do with an LCD including custom character sets, cursors, etc. These vary between LCD driver chips and the Micromite LCD command just implements the basic display data function that should work across all LCDs.

My answer to all instances of this type of query is that you will have to drive the display directly to do special function that are available on your display.

MOBI's effort sounds great and should help a lot in this regard.


I have wracked my brain trying to find a way of including LCD commands in the basic "write to line/pos/string" to no avail. It only complicates things and in any case, the display "window" is enough for most applications. If you want e.g. scrolling text beyond the "window" limits, you will have to use your own MMbasic code with direct connect or the simple method of i2c where you have the choice of sending commands or data to the LCD. The "direct" method coding is a little more complex than Geoff's built-in LCD commands but for those who want more, the results are worth it.
David M.
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2817
Posted: 04:08pm 26 Feb 2014
Copy link to clipboard 
Print this post

As mentioned in my last post, I would simply use something like SETTICK 500,CFlash,4 to set up a timed interrupt every half second to a 'CFlash' sub.

Then in the 'CFlash' sub simply toggle between the required cursor character and a blank character at the LineNo & ChrPosition (stored in variables) where you want the cursor to flash.

Yes I know LCDs have a lot of 'built in' hardware commands (one of which is cursor blink) but like Geoff says these vary between driver chips. The code I suggest above is probably the simplest way to achieve a cursor effect in a manner that is simple to use (which after all is what Basic is all about!)


For everything Micromite visit micromite.org

Direct Email: whitewizzard@micromite.o
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 06:33pm 26 Feb 2014
Copy link to clipboard 
Print this post

Hi Phil/David/TZ,

This bit of code works without resorting to I2C stuff but I'm not sure how to 'get out' of it. It seems to me you need to use two timer interrupts otherwise you spend all your time within the interrupt routine. The PAUSE statement is a bit crass but it's only executed once going into the cursor routine.
.....Waiting for an avalanche of better ideas here!

Greg

LCD INIT 2, 3, 4, 5, 23, 24
lcd clear
LCD 1,1,"SET TIME xx:xx"

cursor:
settick 500,flashON,1
pause 300
settick 500,flashOFF,2
do
'
'Keypad input & LCD character advance routine
'
loop

flashON:
LCD 1,10,"_"
ireturn

flashOFF:
lcd 1,10," "
ireturn
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 07:35pm 26 Feb 2014
Copy link to clipboard 
Print this post

I just send code 0x0F to get a flashing block cursor.
No timers or any other code needed.
But it can be specific to my LCD although it is using a standard HD44780 compatible controller.
here is a list of control characters:
http://www.geocities.com/dinceraydin/lcd/commands.htm Edited by TZAdvantage 2014-02-28
Microblocks. Build with logic.
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 08:01pm 26 Feb 2014
Copy link to clipboard 
Print this post

How do you send the 0x0F using uMite code though Jean?
BTW I hope you're keeping clear of all the ruckus over there - is it affecting normal life much?

Greg
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6102
Posted: 08:13pm 26 Feb 2014
Copy link to clipboard 
Print this post

  paceman said   How do you send the 0x0F using uMite code

Greg


LCD 1, 2, "Distance"+chr$(15)

I tried with my LCD display and get a solid (non flashing) cursor

I also tried chr$(14) and chr$(12) with the same result.

Jim


VK7JH
MMedit   MMBasic Help
 
MOBI
Guru

Joined: 02/12/2012
Location: Australia
Posts: 819
Posted: 08:41pm 26 Feb 2014
Copy link to clipboard 
Print this post

  Jim said  I tried with my LCD display and get a solid (non flashing) cursor

I also tried chr$(14) and chr$(12) with the same result.


As you will. Ascii characters start at chr$(32) = space. All control characters give a flashing solid block.

If you want to display 15, you will need to convert it to a string.


David M.
 
     Page 5 of 7    
Print this page
© JAQ Software 2024