News:

;) This forum is the property of Proton software developers

Main Menu

Advice on using Arrays

Started by Dave-S, Nov 22, 2025, 11:59 AM

Previous topic - Next topic

Dave-S

Sending Hex data to a 4D system display which requires data in Hex format, the following works ok and shows a polygon correctly on the display and gives the correct response 06. I want to use an array to save writing a lot more code by just changing certain elements.

HSerOut2 [0x00, 0x14, 0x00, 0x04, 0x00, 0x2B, 0x00, 0x25, 0x00, 0x34, 0x00, 0x3A, 0x00, 0xFA, 0x00, 0xF0, 0x00, 0xE2, 0x00, 0xEA, 0xF8, 0x00] response 06 and shows on display.

Creating an Array and I have to put the Decimal value in it and then use Hex format to send:-
ie: HSerOut2 [Hex array[0], Hex array[1], ...................]
sending this I get response 15, (NAK) but nothing appears on the display.

The output of the array sent to serial terminal I get
00140004002B00250034003A00FA00F000E200EAF800, but the output from the output of HSerOut2 which works ok is in the format 0x00, which is the format specified by 4D systems.

Syntax: cmd(word), n(word), vx1(word), vxN(word), vy1(word), vyN(word), colour(word)

Byte Stream:
cmd(MSB), cmd(LSB), n(MSB), n(LSB),
vx1(MSB), vx1(LSB), vx2(MSB), vx2(LSB), vx3(MSB), vx3(LSB), 4(MSB), vx4(LSB), vy1(MSB), vy1(LSB), vy2(MSB), vy2(LSB), vy3(MSB), vy3(LSB), vy4(MSB), vy4(LSB), colour(MSB), colour(LSB)

0x00, 0x14, 0x00, 0x04, 0x00, 0x2B, 0x00, 0x25, 0x00, 0x34, 0x00, 0x3A, 0x00, 0xFA, 0x00, 0xF0, 0x00, 0xE2, 0x00, 0xEA, 0xF8, 0x00
4D tech not very helpful on Protocol.

Is there any way to send that format using an array? any suggestions?
Tried using WORD variables as it states is the Syntax, but does not work.
Have tried using STRING variables but does not work.

Thanks David

trastikata

#1
Try this code:

Dim myWordArray[11] As Word = 0x14,0x04,0x2B,0x25,0x34,0x3A,0xFA,0xF0,0xE2,0xEA,0xF800
Dim bCounter As Byte
Dim wTemp As Word

For bCounter = 0 To Bound(myWordArray)
    wTemp = myWordArray[bCounter]
    HSerOut2[wTemp.Byte1, wTemp.Byte0] 
Next

Dave-S

Thanks for the reply.
It did not work directly but I have been able to get it working.
I had originally tried creating a Array with Hex values but the compiler said "it does not support Hex in arrays", but that was a Word array, it appears to work with a Byte array.
The display requires all command sent in one serial command, has to respond with ACK 0x06, sending via a For loop does not do that.
Sending all the Array in one line seems to work, including changing elements via multification/subtract/addition.
Thanks for your help.
'*************Filled Polygon 1****************
Fpolygon_1:
Dim ARP1[22] As Byte = 0x00, 0x14, 0x00, 0x04, 0x00, 0x2B, 0x00, 0x25, 0x00, 0x34, 0x00, 0x3A, 0x00, 0xFA, 0x00, 0xF0, 0x00, 0xE2, 0x00, 0xEA, 0xF8, 0x00

HSerOut2 [ARP1[0], ARP1[1], ARP1[2], ARP1[3], ARP1[4], ARP1[5], ARP1[6], ARP1[7], ARP1[8], ARP1[9], ARP1[10], ARP1[11], ARP1[12], ARP1[13], ARP1[14], ARP1[15], ARP1[16], ARP1[17], ARP1[18], ARP1[19], ARP1[20], ARP1[21]]

Return