top of page

SCADA Print (the faster way)

So to add a SCADA compatible Print to the SCADA firmware.

First make a copy of the code as SCADAPrint.fcfx (or a name of your choice)

Add the display of your choice. I used a ssd1306(i2c).

Add a constant for OLEDPRINT (0xB0) and OLEDCLS(0xB1) - note that having a initialisation is optional - it makes sense just to initialise the display in the Main routine and this is what we do here.

Note - subtracting FCL_OFFSET (128) from the command byte is used to reduce the size of the command vector. All the FC commands start at 128 - and we have 128 to play with (less the 20 or so currently used) We could increase the size of Actors to 256 and allow 256 commands (0..255) if needed.

Create two new macros OLEDPrint, OLEDClear and OLEDInit all of which take no arguments and return a byte.

OLEDClear just calls the initialisation and clear routines of your chosen display and returns 0 (no return data to be sent).

OLEDPrint takes X and Y coordinates and a string to print. Note it will always print in size 2 and transparent (my chosen settings) - if you wished you could pass these as parameters as well. It also returns 0.

The routine to print a string is slightly more involved - notice that the string is copied from the command buffer (from position 3 onwards) to a local string - this copy also includes the 0 terminator of the string.

These can then be used from within a SCADA application running on the PC. It is necessary to create a macro to pass the required command to the UART. In the case of print also pass the co-ordinates and the string to be printed.

SCADAClear just sends a 'start' byte the 'clear' command then the two end bytes (0x3b and 0x0a) Here they are shown as single byte writes - we will look at alternative methods later...

Then it waits for a 'reply' from the Arduino. This should be the command (0xB1) - but we do not test here...

Print is slightly more complicated - we must send the command, the co-ordinates and the string (including the 0 terminator)

Again we wait for a reply...

The main program is as follows - this simply prints a string ("Hello") at a random position - then clears the display after 10s..

Test this works first! - I had forgotten to change the size of the display from 128x64 to 128x32.

Then you can easily control the display from within a SCADA program..

44 views0 comments

Recent Posts

See All
bottom of page