TOF10120 Laser Range Sensor Module

stan74

Senior Member
There was a hint on gcb forum about converting c+ to basic and explained what c+ code meant at a simple level
but was just a starter.
converting basics is also hard . Ever used Freebasic? boy that can be easy or difficult.
I've tried converting proton basic device code,again a pain.
python to basic...forget it!
Does anyone else think data sheets are too complicated?
Ili9341 glcd is a pain but seen it sorted in a few basics...and c+
 

stan74

Senior Member
here's a video of sort of measuring distance.
ps a constant reading of 20mm means all obstacles out of range! check that.
and the code is
;V53L0X range finder to terminal for nano clone
#chip LGT8F328P,32 ;#chip mega328p,16 ... #chip is the chip in use so for uno ;#chip mega328p,16
#option explicit
;#include <LGT8F328p.h

;for terminal distance out
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
#define USART_DELAY 1 ms
;set up v53l0x
#define HI2C_DATA PORTC.4;sda pin for nano! portc.5 for uno!
#define HI2C_CLOCK PORTC.5 ;scl pin for nano! portc.4 for uno!
#define HI2C_BAUD_RATE 400
HI2CMode Master
;main Get Distance----
dim distance_lo,distance_hi as byte

HI2CStart ;software restart
HI2CSend(0x52)
HI2CSend(0x89)
HI2CSend(0x01)
HI2CStop
wait 200 ms
do ;------------------------
HI2CStart ;Sys Range Start
HI2CSend(0x52)
HI2CSend(0x00)
HI2CSend(0x01)
HI2CStop

HI2CStart ;read distance
HI2CSend(0x52)
HI2CSend(0x1e)
HI2CReStart
HI2CSend(0x52 or 1) ;set the read flag
HI2CReceive(distance_hi)
HI2CReceive(distance_lo, NACK) ;read one byte and conclude
HI2CStop
wait 500 ms
hserprint "Distance= "+str(distance_hi*256+distance_lo)+" mm"
HSerPrintCRLF
loop
 
Last edited:

stan74

Senior Member
What would that be in picaxe basic?
It came via picaxe basic from another basic and was stripped of unneeded setup variables unlike the c+ version which is full of not needed stuff.
 

stan74

Senior Member
Hi,

From another thread it appears to be: :)
Code:
hi2csetup i2cmaster, 82, i2cfast, i2cbyte
do
   pause 500
   hi2cout 0,(1)
   hi2cin 30,(b7,b6)
   sertxd("Distance= ",#w3," mm",cr,lf)
loop
Cheers, Alan.
Hi,

Thanks for replying @AllyCat. The picaxe thread about V53L0X I looked at, the code seemed more.
I still got the picaxe boards I built on vero/stripboard. They've all got a 3.5mm jack socket for prog data and clock from a picaxe rs232 d plug to
3.5mm jack plug.
I was never understanding i2c ,just enough to use it.
I never used serial print cos never figured it out..how to use a terminal.

The picaxe i2c hardware pin, baud etc. is sort of condensed into a special routine that does more than other languages...
well different but that's the point,basics are different.
There are many cheap devices on the internet that look interesting but often say for arduino or rpi, never any reference to basic,
so either convert code or learn the very tech data sheet...if it's in english it "helps".
I don't have a workshop and a partner to nag me so my workbench is a coffee table in the living room so I can still watch tv and the kitchen table.
When my 6 year grandson comes round it's "what you making grandad?".
I let him wire 8 white leds to breadboard with a common resistor and showed how to "program them" .
he got the long and short lead the correct way when I showed him the first.
Entertaining a 6 year old is a challenge :)
 

Haroen

Member
@AllyCat
Ok, I'm already configuring the dedicated hardware "tester" in my head with all good advise given.
The advise to "Keep It Simple" is very true so "Tabular" (Table) display is indeed a "Gimmick" on a display. Just the essentials!
I intend to place both a KISS 4pins header and the Universal 8pins header and leave the existing code as it is, just some additions also for the display.

I have yet to study the SSD1306 and the "Bit Banged" I2C code.
I did not know a I2C(2) is possible and on a PICAXE :D
Thanks for the VL53LOX(ordered but not yet arrived) source code.

@stan74
Thanks for the code.
Is it for gcb code and could it work on other Arduino boards other than the Logic Green LGT328p ?
I downloaded great cow basic for reference and orientation.
here's a video of sort of measuring distance...
I noticed in the video with the fixed laser sensor and a book at a fixed distance that the sensor readings can vary about 8 mm?
Is that correct and could it be light interference or an issue in the code?
Because the TOF10120 had much less with this picaxe thread code.

Teaching your grandson of 6 year old is great :)
 
Last edited:

AllyCat

Senior Member
Hi,
I intend to place both a KISS 4pins header and the Universal 8pins header and leave the existing code as it is, just some additions also for the display.
Still with an 08M2 ? The "ASCII Art Header" in the original Program has only 6 pins, but you could add SDA and SCL, one at each end, to increase the possible number of pin combinations, but I think that "splitting" the I2C bus with the Supply and Ground in the middle is unusual. However, "ZIF" Sockets are quite common for "Test" equipment, they were very expensive, but it seems you can now get them quite cheaply, perhaps less than the price of a toggle switch?

ZIFsocket.jpg

The 16 pins could give more combinations of connections, without the need for any switches. Or with a few M/F "Dupont" cables, up to 4 breakouts could be put on the same bus! Or put additional functions on the pins: V+ = 3.3 volts, "Bus 2", pullup resistors, etc.. You can do a lot with 16 pins (but I'm straying away from the KISS principle :) ).

Code:
 Prog --@-----\/\/\-----+ 100k    Vdd    _ ZIF SOCKET _
        |   ____ ____   |      SO  |    | |          | |
        |  |    U    |  |       |  |    |O| SDA  SCL |O|      
 Vdd ---|--| V+   0V |--@-- 0V  |  @----|O| V+    V+ |O|
        +->| SI  C.0 |>---------+  |  +-|O| GND  GND |O|
      +--<>| C.4 C.1 |<>-- SCL ----|--|-|O| SCL  SDA |O|
      |  ->| C.3 C.2 |<>-- SDA ----|--|-|O| SDA  SCL |O|
      |    |_________|             +--|-|O| V+    V+ |O| 
      +-------------------------------@-|O| GND  GND |O| 
                                        |O| SCL  SDA |O|
             "Universal" ZIF I2C header |_|          |_|
Or perhaps better to arrange the 4 "corner" groups of 4 pins for the most common I2C header arrangements such as: GND : V+ : SCL : SDA or V+ : GND : SCL : SDA , etc.

Cheers, Alan.
 

stan74

Senior Member
@AllyCat
Ok, I'm already configuring the dedicated hardware "tester" in my head with all good advise given.
The advise to "Keep It Simple" is very true so "Tabular" (Table) display is indeed a "Gimmick" on a display. Just the essentials!
I intend to place both a KISS 4pins header and the Universal 8pins header and leave the existing code as it is, just some additions also for the display.

I have yet to study the SSD1306 and the "Bit Banged" I2C code.
I did not know a I2C(2) is possible and on a PICAXE :D
Thanks for the VL53LOX(ordered but not yet arrived) source code.

@stan74
Thanks for the code.
Is it for gcb code and could it work on other Arduino boards other than the Logic Green LGT328p ?
I downloaded great cow basic for reference and orientation.
Yes,just change #chip mega328p,16 for a uno
 

stan74

Senior Member
The ssd1306 I sorted for picaxe but you got pinch just the setup and any plot print code.
The display needs 1K ram for full screen so use a 28x2 with 1.5K ram.
 

Haroen

Member
Of-Topic for reference only:

My installation and study of Great Cow Basic with test on both the PICkit2 and PICkit3:

FINDINGS
* Programming with the "HexFlash" icon on the iconbar for the PICkit2 + 3 results in errors that the HexFile has been created but not programmed to the chip!
* After manually programming the hex file to chip using the "PICkit2 or 3 Programmer", the onboard test LED works, but not according to the source code times!

Can't affort more time for it yet.
 

tmfkam

Senior Member
Of-Topic for reference only:

My installation and study of Great Cow Basic with test on both the PICkit2 and PICkit3:

FINDINGS
* Programming with the "HexFlash" icon on the iconbar for the PICkit2 + 3 results in errors that the HexFile has been created but not programmed to the chip!
* After manually programming the hex file to chip using the "PICkit2 or 3 Programmer", the onboard test LED works, but not according to the source code times!

Can't affort more time for it yet.
There is a forum for this "alternative" BASIC, if you make a post over there I'm sure you will get some assistance. I would initially suggest that the programmer priority is incorrect. But you need to discuss this on there to get a resolution.
 

stan74

Senior Member
I agree with tmfkam. The alternative forum is where to post. In the ide you click IDE tools, then GCB tools, then progammer preferences, then click Microchip Pickit2 summat and drag to top and that's what will be the programmer. Many to chose.
This is not the place to post about using another basic but converting code I think is ok.

Well the
TOF10120 Laser Range Sensor Module
has arrived and I tried to convert picaxe
' hi2csetup i2cmaster, $A4, i2cslow, i2cbyte
'
'Main:
' hi2cout (0)
' hi2cin (b2,b3)
' w2=255*b2+b3
' Debug
'Goto Main

to another basic and had to ask the forum as my conversion was incorrect. I got this as equivelent to picaxe code and looks longer.
#chip mega328p,16
#option explicit
;for terminal distance out
#define USART_BAUD_RATE 9600
#define USART_TX_BLOCKING
#define USART_DELAY 1 ms
;
#define HI2C_DATA PORTC.4 ;sda
#define HI2C_CLOCK PORTC.5 ;scl
#define HI2C_BAUD_RATE 400
HI2CMode Master
Dim I2C_Address, RegAddress as Byte
I2C_Address = 0xA4
RegAddress = 0x00

;main Get Distance----
dim distance_lo,distance_hi as byte
do
HI2CStart
HI2CSend(I2C_ADDRESS)
HI2CSend(RegAddress)
HI2CReStart
HI2CSend(I2C_ADDRESS+1) ;indicate a read operation
HI2CReceive distance_hi, ACK
HI2CReceive distance_lo, NACK
HI2CStop

wait 500 ms
hserprint "Distance= "+str(distance_hi*256+distance_lo)+" mm"
HSerPrintCRLF
loop


Anyway it reads distance around 20cm ok but freezes at 10 or 30cm.
I haven't tried using serial read distance yet.
Thanks guys for the info and links so far. It helps a lot with a new device.mmotte.jpg
 

Haroen

Member
With some gcb forum help gcb now works on PICkit2+3 and have tested some code on PIC's and works ok.
I've got an Atmel ice programmer but not yet an Arduino(only in my 3Dprinter) so can't test any of @stan74.
Which Arduino do you guy's know is best to only buy that is backwards compatible with all older ones and can work with all Arduino sourcecodes?
This question is only for testing and verifying code presented in this and maybe other threads.

Well the TOF10120 Laser Range Sensor Module has arrived and I tried to convert picaxe
...
Anyway it reads distance around 20cm ok but freezes at 10 or 30cm.
I haven't tried using serial read distance yet.
I didn't have that problem with PICAXE code, have you tried that?
Otherwise I think it is a conversion problem.
 

Haroen

Member
For the I2Cscanner display I tried this code, but it gives me this error:
The bit-mapped display maps quite well to a "1602" (8x16 pixels ASCII font) or "2004" (6 pixels wide characters), using "Double Height" characters for the 128 x 64 pix version. Most of the "font" coding is already done and documented HERE , but I still need to finalise the HSERIN input code, to support the much more intensive (complex) and slower (bit-mapped) display driver.

symD :hi2cout addr,($08, $08, $08, $08, $08) : return ; -
^
Syntax error on line 148 at/before position 6

Error: syntax error

Is it because it has not finalised HSERIN input code?
 

AllyCat

Senior Member
Hi,
Which Arduino do you guy's know is best to only buy that is backwards compatible with all older ones and can work with all Arduino sourcecodes?
IMHO you are exceeding the bounds of a PICAXE forum which is paid for by a commercial company. See the "Read this First" thread:

"This forum is for any PICAXE related discussion - help with projects, general advise etc. No advertising....".

Cheers, Alan.

PS: Look to where the "^" is pointing. ;)
 

stan74

Senior Member
You are correct Alan. Thing is many cheap and interesting devices have a difficult to understand data sheet...in english if your lucky
but there's a working arduino solution or a solution in another basic.
Hippy and others do their best to help with getting devices to work with picaxe for users but often working c+ code or another basics code might be more easy to convert to picaxe than starting from scratch with a data sheet.
What picaxe needs is a new "expert" to update it to 2021 if it is to continue as a commercial product.
I paid for chips with picaxe printed on them and bought the rs232 to 3.5mm jack plug so think it ok posting about other dev system code
to get working with picaxe and converting my picaxe code to other code.

I pushed forums tolerance and apologise but on a plus it keeps the forum alive with activity.
let's celebrate what we have in common, ie getting a ucntrl to do what we want :)
 

Haroen

Member
...so can't test any of @stan74.
This question is only for testing and verifying code presented in this and maybe other threads.
Sorry, not my intend to break any rules!
...Thing is many cheap and interesting devices have a difficult to understand data sheet...in english if your lucky
but there's a working arduino solution or a solution in another basic.
Hippy and others do their best to help with getting devices to work with picaxe for users but often working c+ code or another basics code might be more easy to convert to picaxe than starting from scratch with a data sheet.
That's what I've seen too when surfing for parts(sensors, displays & actuators, etc) always saying... "For Arduino" with libraries out of the box working.
Part sites pushing us to arduino, me definitely not liking C+!
I see the combination gcb and arduino as a solution to quickly find or at least help to figure out how to program the PICAXE.
Don't like it that my PICAXE project is more difficult to complete (hardware & firmware) wise.
The forum is then the only solution that works.

PS: Look to where the "^" is pointing. ;)
If I remove the symD in the line:
Code:
on subchar goto sym0,sym1,sym2,sym3,sym4,sym5,sym6,sym7,sym8,sym9,symA,symB,symC,symE
And remove the line
Code:
symD :hi2cout addr,($08, $08, $08, $08, $08) : return ; -
(That also represent numB for "-")
Code:
numB: hi2cout addr,($00, $56, $36, $00, $00) : return ; -
There are no errors anymore.

I don't see a serin command and input-pin declaration to receive the to be displayed message if this 08M2 will be a SSD1306 driver.

I have instead of the 4pin-header display a 7pin-header SSD1306 display with extra Res, DC, CS.
Circuit set like this where Res=PulledUp or PulledDown in combination with the 08M2 sourcode doesn't show anything on the display?
 
Last edited:

AllyCat

Senior Member
Hi,
There are no errors anymore.
There ARE if you try to show the characters stored as : symD ( - ) , symE ( . ) or numB ( ; ) [i.e. ASCII 45 , 46 and 59 ] , you did NOT need to REMOVE anything. There were two small "typos" in the listing (which I have now corrected).

With most computer languages, EVERY character can be important, so look very carefully at the POSITION of characters such as the " : " and particularly the <space> (sometimes known as "White Space") in the "Error" messages you found above.

IMHO, unlike the "horrible" C{++} language , you should be able to solve these syntax errors for yourself. ;)

Cheers, Alan.
 

stan74

Senior Member
So Alan sir.what's the hserin code for reading this device as it is interesting. Seems it sends 5 bytes so
I think the code was posted but please refresh me as to picaxe code to read the distance using hardware serial.
Sorry to be asking so much but it's a new device and can't translate the data sheet. the joys of coding.did I mention I'm sarcastic :)
Your feedback is much appreciated as you seem a brighter crayon in the box than me mate.
 

stan74

Senior Member
@Haroen sir go to gcbforum for gcb not here as picaxe users are very dedicated to picaxe and I think I only get away with my posts is that I conversed with hippy and others on cross platform projects in the past but that was getting picaxe code to work.

To be honest...if you want interesting devices to work and can't with picaxe then try something else but you may find that something else also doesn't support that device :)

to be honest I think arduino has everything sorted but I don't/can't use the c+ language...
there's an include for anything and it pisses me off I can't get into c+
This ain't recent...I never got on with c+

so try gcb and post on their forum https://sourceforge.net/p/gcbasic/discussion/
we all use basic and there's picaxe users to help you on gcb. Just join/sign in
 
Last edited:

stan74

Senior Member
I got the chinese pdf but looking up google translate pdf not translate page. Yawn.
How do I connect tx sensor to rx input and rx sensor to tx input and read hserial in?
does it need a start or just sends bytes,,5 at a time it seems.
 

AllyCat

Senior Member
Hi,
...what's the hserin code for reading this device as it is interesting. Seems it sends 5 bytes so I think the code was posted...
There should be sufficient details about reading the TOF10102 on the first page of this thread. The I2C is just two data bytes and the serial "continuously" sends sufficient raw ASCII digit characters, + "mm", <CR> and <LF> . That's all I know since I've never used one.

Cheers, Alan.
 

stan74

Senior Member
Hi,

There should be sufficient details about reading the TOF10102 on the first page of this thread. The I2C is just two data bytes and the serial "continuously" sends sufficient raw ASCII digit characters, + "mm", <CR> and <LF> . That's all I know since I've never used one.

Cheers, Alan.
Thanks Alan? I only came across the device on picaxe forum.I never heard of the device before.
I'll try read serial later.
It's not the same as V53L0X as it uses trig to measure distance but V53L0x doesn't. I don't really think is is TOF as light travels to fast.
It uses avalanche sensors... so maybe it uses trig also.
Interesting devices for around £5. I can afford that and get my monies worth just in head scratching :)
 

Haroen

Member
@stan74, AllyCat(Alan) is correct, check out post #20 is the code you need.

IMHO, unlike the "horrible" C{++} language , you should be able to solve these syntax errors for yourself. ;)
🤓 Yep, I know I should have used me glasses to see that, error solved.

However, doesn't show anything on the display, it's totally dark?
I don't see a serin command and input-pin declaration to receive the to be displayed message if this 08M2 will be a SSD1306 driver.

I have instead of the 4pin-header display a 7pin-header SSD1306 display with extra Res, DC, CS.
Circuit set like this where Res=PulledUp or PulledDown in combination with the 08M2 sourcode doesn't show anything on the display?
 
Last edited:

AllyCat

Senior Member
Hi,
It's not the same as V53L0X as it uses trig to measure distance but V53L0x doesn't. I don't really think is is TOF as light travels to fast.
It uses avalanche sensors... so maybe it uses trig also.
Where did you get that information? The "DroneBot Workshop" review (post #4) seems to think it's TOF (isn't the part number a clue?) and the Manufacturer's Data sheet says:

"TOF10120 range sensor provides accurate and repeatable long range distance measurement for high-speed autofocus (AF). The innovative time-of-flight technology allows performance independent of object reflectance. TOF10120’s time-of-flight sensing technology is realized by Sharp’s original SPAD (Single Photon Avalanche Diodes ) using low-cost standard CMOS process. It enables accurate ranging result, higher immunity to ambient light and better robustness to cover-glass optical cross-talk by special optical package design."

The problem is that Sharp refuse to give any details of how to calibrate their device and insist you must use their (1000s of lines of code) "API". The (possible) advantage of the TOF10120 is that it "hides" all this from the user.

Cheers, Alan.
 

AllyCat

Senior Member
Hi,
However, doesn't show anything on the display, totally dark?
My program is for the 128 x 32 I2C-only (4 pin) modules. There are other threads on the forum which configure the 128 x 64 I2C version, but it seems you have a "SPI" version. I do not know if your module can be switched between modes, the only information I have, from the SSD1306 Data Sheet is:

"8.1 MCU Interface selection
SSD1306 MCU interface consist of 8 data pins and 5 control pins. The pin assignment at different interface
mode is summarized in Table 8-1. Different MCU mode can be set by hardware selection on BS[2:0] pins
(please refer to Table 7-1 for BS[2:0] setting)."


SSD1306modeT7.png

SSD1306mode.png

If you can't find the BS[2:0] connections then your display is probably for SPI only.

Cheers, Alan.

PS: It does appear that the larger (1.3 inch) modules for SPI and I2C are definitely different:

SSDoptions.png
 
Last edited:

Haroen

Member
After carefully studying the 08M2 code for SSD1306 I found...
Code:
symbol EPROMSAD = $A0           ; Slave ADdress
symbol OLEDSAD = $78               ; Slave ADdress
* That's an external EPROM, what kind and type?
* Could my 7pin-header SSD1306 display with extra Res, DC, CS have another address?
* The I2Cscanner doesn't find the 7pin-header display address.
* SPI could explain the the problem, but why are there pins for I2C(scl, sda)?
 

stan74

Senior Member
The ssd1306 needs a 1kb data buffer to use and only 28x2 with 1.5k ram will do it from my picaxe experience. Sorry mate 08M2 not.
I posted the ssd1306 driver for picaxe recently and that was a collaboration at the time of making.

Why would the spi version be different? Interesting. I will check but do not see there would be display ram on the display.
Get back when I checked.
This was easy with enough ram for ssd1306
 
Last edited:

stan74

Senior Member
Hi,

Where did you get that information? The "DroneBot Workshop" review (post #4) seems to think it's TOF (isn't the part number a clue?) and the Manufacturer's Data sheet says:

"TOF10120 range sensor provides accurate and repeatable long range distance measurement for high-speed autofocus (AF). The innovative time-of-flight technology allows performance independent of object reflectance. TOF10120’s time-of-flight sensing technology is realized by Sharp’s original SPAD (Single Photon Avalanche Diodes ) using low-cost standard CMOS process. It enables accurate ranging result, higher immunity to ambient light and better robustness to cover-glass optical cross-talk by special optical package design."

The problem is that Sharp refuse to give any details of how to calibrate their device and insist you must use their (1000s of lines of code) "API". The (possible) advantage of the TOF10120 is that it "hides" all this from the user.

Cheers, Alan.
I got a sharp distance sensor with ubiquitous 2 eyes analogue out for distance and it was waste of £7.
I think these laser rangefinders use a "similar" technology...but work better in using for robot obstacle avoidance.
they are fast-ish and just nice to use. well reading ad would be easier than serial. cheers

these distance sensors are nice to use.my favourite is v53l0x. what is yours and how was it used?
hsr04 brill really. lasers got more "precision"
 
Last edited:

AllyCat

Senior Member
Hi,

Nearly all of this is explained in my FINISHED PROJECT so I'm not going to write it all out again. There's no need to store ANY data locally in RAM for a basic character display. Actually, data CAN be read back from the SSD1306, but unfortunately only via the "Parallel" bus, not via I2C or SPI.

The external (EEPROM) memory is only required for multiple Font (character) sizes (single/double/quad -height, etc.) and can be almost any serial type on the I2C bus. The one I used was probably a 24LC256, maybe on the RTC module that is shown on the right of the photograph in that thread.

Like many ICs, the SSD1306 Integrated Circuit is designed to support both SPI and I2C buses. However, it is probable that the manufacturer of the Display Module has decided to configure their boards for either SPI or I2C (rather than bring out more pin connections that rarely will be needed).

Cheers, Alan.
 

stan74

Senior Member
the idea that picaxe could be connected to another pic that runs a display and haveing say a pic and a 328p as a driver is both interesting and also silly.
let's not say another compiler that runs the glcd with a include lib but a way to interface the two as picaxe is too slow to do graphics but like a nextion display could do much quicker.
A nextion is a pain to use.yes or no to that.
costs a lot. less price a glcd and a say nano.
The nano will have the glcd drivers but commands to use them with picaxe.
A picaxe interface would be an alternative to nextion.
let me know what you think and I will post on another forum.
 

Haroen

Member
Things are getting more clear with every post of your help, thanks.o_O

To put all info sofar in perspective(please correct me if I'm wrong)...
* Didn't now the diversity of SSD1306 displays! I thought that sda+scl always means I2C in their communications. So I will order a new 4pins display.
* But still SSD1306 displays are essentional parts that I (and a lot of people) can use in many existing and future (low power, compact and lightweight) projects.
* Even to replace project displays for instance, about 5 years ago, where I used a red 4 digits LED DOT matrix for heating temperature in °C and very short error messages with running text.:ROFLMAO:
* So while designing new projects and upgrading old ones with a SSD1306 display it could sometimes be easier to just add another PIC(axe) or AVR as a display driver. I did that with a previous project where I used the picaxe 20X2 driver by @marks to drive a 4x20 LCD, and works great. Less rerouting of the old pcb by just adding instead of replacing with a bigger chip.
* Therefore for me the R&D of the 08M2, 28X2 or non-picaxe chips to drive the SSD1306 display is desirable. (And this thread can help others)
* Even with the 08M2 I at least like to see what is accomplished.
* With new projects though @stan74 has a point saying...
the idea that picaxe could be connected to another pic that runs a display and haveing say a pic and a 328p as a driver is both interesting and also silly.
...picaxe is too slow to do graphics...
* Also, besides the slow grahics, the refresh rate of characters is slower with a picaxe.
* But how much faster does a graphic or text needs to be depends on the project where often the PICAXE is fast enough.
* Because of the PICAXE catching BASIC instead of C+, I love to use it as overall master controller.
* External cheaper and faster alternative (display or other) drivers with an Microchip or AVR (with LIB) eventually is also desirable on other forums. The video @stan74 "SSD1306 analogue voltmeter" is impressive!
* Running all (controller and driver code) within one chip (28X2 or non-picaxe) is an good option that I'm trying. (but also where to maybe waste many unused I/O's).

Took me some time to structural write my philosophy on this, but glad to have cleared my mind.🤕
 
Last edited:

Haroen

Member
Nearly all of this is explained in my FINISHED PROJECT so I'm not going to write it all out again. There's no need to store ANY data locally in RAM for a basic character display. Actually, data CAN be read back from the SSD1306, but unfortunately only via the "Parallel" bus, not via I2C or SPI.

The external (EEPROM) memory is only required for multiple Font (character) sizes (single/double/quad -height, etc.) and can be almost any serial type on the I2C bus. The one I used was probably a 24LC256, maybe on the RTC module that is shown on the right of the photograph in that thread.
I'm not the smartest of the class, sorry for asking but to replicate your finished project I could really use a schematic of minimum connections.
Also for replicating the "multiple Font" circuit.
 

stan74

Senior Member
@AllyCat posted a char display I had not seen for ssd1306. https://picaxeforum.co.uk/threads/full-ascii-character-font-for-ssd1306-with-08m2-and-above.32003/
I don't know how I sorted ssd1306 to plot pixels with picaxe, it was over 4 years ago but it was with much help from picaxe forum members!
I may be wrong but compilers for ssd1306 have all used a 1k ram buffer to plot,draw lines.circle. You can even scroll a given number of pixels.
The displays are oled so no backlight and monochrome but different models different colours. Mine is third od screen yellow and rest white...from China for a few £.
What gets peoples goat is they are so small and bigger oled displays cost lots more. This is why I recommended an ILI9341 spi glcd.

The administrators of the picaxe forum are going to get annoyed about posts to different systems and can't blame them
but I'm not trying to suggest people using picaxe change the dev system only that fastish/fluent graphics need a bit of speed or the illusion of movement is lost.

Nextion displays as I said are cool and work with picaxe but no one said "Arghhh! shock horror...not a picaxe product!"
I like the nextion but having to use their gui for initialising the display is a pain..imho.

If any senior forum guys think an interface between another compilers say cheapest 328p and say ILI glcd let me know.
I got an ILI9486L which is spi But also uses a whole port for data lines. It's a very fast display.
If this used a lot of pins on a 328 no problem as the picaxe should if the 328 was programmed to accept serial just send commands to the 328 board.

The alternative compiler can use many displays and many avr or pic chips, so it's the cheapest pic and display.

I will send the idea to the main code writer who's said he'd used picaxe for his feedback.

But will this be welcomed???

tune in next week to find if stan got his bottom kicked :)
 

stan74

Senior Member
I did post the idea to another forum and think the serial idea to use all glcd commands cool. It could be done I think.
Just set up a serial in loop and check the data and sort it. Yeah,easy :)
The ILI9486L I tried was from a guy on the forum and it had touch display but was a "shield" for a uno and covered the board so no access to any pins left cos it used a port for data then the spi pins as well so would be a stand alone unit in practice so the serial idea sounds interesting I think.
 

AllyCat

Senior Member
Hi,
* But still SSD1306 displays are essentional parts that I (and a lot of people) can use in many existing and future (low power, compact and lightweight) projects.

Took me some time to structural write my philosophy on this, but glad to have cleared my mind.🤕
Yes, I understand and agree with nearly all that you say in your philiosophy. ;) To me, one of the great strengths of PICaxe is its very low power and small size.

But perhaps I should quote from my introduction to my ASCII / SSD1306 / 08M2 thread:
" The program was intended as a "core" or "preamble" for further development, ...... The code size is about 1400 bytes, so there is space for around another 500 bytes, even with an 08M2; or some/most of the code might be removed in a final application. ".
I slightly regret posting it in the "Finished / Video Projects" because it was really intended as a "Code Snippet" (where I usually post my programs) rather like a "Library" function with Arduino. The user still needs to understand what the "Library" function does and write their own "Sketch" program.

PICaxe doesn't normally need or use "Include" files (Hooray !), so Library and Sketch are all together, but for that SSD1306 thread the "Sketch" is basically:
Code:
; WRITE FONT TO OLED:
    for index = 32 to 127
        char = index
        call tree
        hi2cout addr,(0)        ; Inter-character gap
    next
which shows how the "tree" function can be used. Of course a few more lines are needed to initialise the system, etc. and more "Library" functions are available (for example "Clear Memory" and "Double-Height"). But it does seem that you need to be very careful about the specification of those OLED displays. Not only are there different I2C and SPI versions, but some use different control Integrated Circuits (i.e. NOT SSD1306); some are "compatible" but not all !

The "Circuit Diagram" can be very simple: Just an 08M2, SSD1306, Download Circuit and a decoupling capacitor! An EEPROM (or RAM or clock chip, etc.) is "optional", unless you want the full 96 ASCII characters at Double-Height, etc.. However, I think an EEPROM is a very good "enhancement" to the design. First you would download a program to write ALL the characters (including double-height, etc.) to the EEPROM. Then you can replace that program with one that doesn't need all the "character images" stored within the PICaxe.

There are probably I2C pullup resistors on the OLED board, or the PICaxe's internal pullups can be used. Here is an "OLED module" (both sides shown) that I've been planning (NOT yet finished), which is the size of an AA battery, so that it can fit into a standard "battery box", together with a few AA cells (1 x Lithium or 2 x Alkaline or 3 x NiMH, etc.) to power it. In this particular design the Transistor is to invert the HSERIN signal (i.e. an RS232 input), but in other designs it might be a FET to switch an external circuit, etc.. The HSERIN (Interrupt-driven) is almost "essential" so that more characters can be received whilst the pixels are being written to the OLED. Note that the 0V , A2, A1, (A0) pins of the EEPROM are linked on the TOP side of the board.

SSD1306AApcb.png

Cheers, Alan.
 

stan74

Senior Member
AllyCat said "To me, one of the great strengths of PICaxe is its very low power and small size."
they same size of pics but not smd and same power??
The main complaint about picaxe from other users is it's variable use. peek and poke variable is no fun and not sure about defining lots of vars.
This is the main "complaint" about picaxe on other forums. It's the main weakness for user use as it's not like other basics even allowing
for it's basic for pics.
Otherwise if it does the job for you then nice.
If it doesn't then expand your focus.
Get what you want for micro controllers from where you want and use what suits you.
it will not be on a plate often but that's what makes it interesting. ... that's programming in general to me.
 

stan74

Senior Member
The idea of a "graphic" display is possible in picaxe but not easy.
Using any display is going to use the data sheet and then "set" the device up,,,which is not easy.

This why not use a slave glcd. Say I got any gldc supported to work and doing nothing in a loop,
Then
do
get serial code from picaxe
Sort it as start of transmission then parameters then execute command
like receive 255 then wait then next bytes are commands for glcd commands.
loop
you guys know what I'm on about I guess
 
Top