How to display Variables from a script on to an OLED using simulink

hello
I am having an issue displaying variables on my OLED Display (ssD 13150) im a bit new to matlab and think i need to use simulink but am not sure and vcant find to much info on using oled displys in matlab , does anyone have any resources or tips they can give me

 Accepted Answer

https://www.mathworks.com/help/supportpkg/arduino/ref/adxl343-read-acceleration-tap-count-oled-io-device-builder.html shows an example of creating custom I/O blocks that use I2C to talk to an OLED that is compatible with SH1106 . I am not sure if you will need to go that far

14 Comments

okay so ive read over the exmaples and from my undertanding i need to use an I2C controller write block toi use for writing text onto the oled display ? Although im bit confused with finding slave address . Also if i just wanted to display a variable on the oled that has a constant value do i need to use simulink or is there a write function I can use , like a write function ?
You do not need to use Simulink to write to an OLED attached to an arduino. At the MATLAB level you would create the arduino object, probably asking for the appropriate Adafruit library to be loaded, and you would use the arduino I2c functions https://www.mathworks.com/help/supportpkg/arduinoio/i2c-devices.html
okay so i looked at the resoucres your provided and think i made some progress , i tried making a test scrpit :
clear
a = arduino('COM8','Nano3','Libraries','I2C')
addrs = scanI2CBus(a)
dev = device(a,'I2CAddress','0x3c')
data= [ 1 2 3 4 5]
write(dev,data)
But my oled does not display anything and appears to be off , i think im misisng some sort of intilizing function , I found a library that I think i need to use : https://github.com/adafruit/Adafruit_SSD1306
could you point me in the right direction ?
yeah thats what i was basing my code off but oled doesnt turn on
I am having difficulty finding an OLED with part #13150 . Are you possibly using a 3150 ? https://www.adafruit.com/product/3150
I suspect not as the address for that has to be 0x70 to 0x77
I think we are thinking about two diffrent devices
The slave address for that device is either '0x3C' or '0x3D'; you would typically use 0x3c for the "left" display if you are using two of them.
You can writeRegister() a stream of bytes. The bytes must be in pairs.
If the first (0x80) bit of the first of the pair is 0 then the next bit should be 1 and rest of the bits in the byte should be 0, and the second byte must be a data byte, and that must be the end of the sequence -- so 0x40 then the last byte. (Except as I read the manual, 0x00 then the last byte should work as well, but there is a potential contradiction in the documentation and 0x40 would be safer.)
If the first (0x80) bit of the first of the pair is 1 then the next (0x40) bit determines whether the following byte is a command byte (bit is 0) or a data byte (bit is 1), and the remaining 6 bits of the first byte must be 0. There must be additional bytes in the sequence.
There is an implication that every sequence of bytes must end in 0x00 followed by a data byte -- and therefore there are no "pure command" sequences.
You can send a pure sequence of data bytes by interleaving 0xc0 <data> until a final 0x40 <last data> . Each of those data bytes would be stored in the next location in memory.
The command table starts at page 37 of https://cursedhardware.github.io/epd-driver-ic/SSD1315.pdf
It looks like "display on and clear" is 0xA5 and "display on without clearing" is 0xA4 ... except 0xAF also appears to be to set the display on.
okay sweet thanks ill give that a try right now and let you know how it goes thanks boss man
Note that what gets sent as data to the display is not characters -- not unless the adafruit library provides an interface to help with that.
What gets sent as data is a byte whose bits become vertical pixels. It is up to your code to rasterize the output you want to create something useful to the user. (I would guess that the library contains routines that assist with that.)
For example you might want to construct an array of rendered monospace characters in an 8 pixel by 8 pixel typeface as a bit-map, and then convert the binary columns to 8-bit bytes.
hey so ive been trying to fiddle with the oled and the doc you sent but i cannot for the life of me print to the oled , would you be able to provide me with a code for printing hello world to the oled so i can try top reverse engineer it

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2023b

Asked:

on 21 Oct 2023

Commented:

on 25 Oct 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!