Dynamic C(Teso PC1620-PLC)控制LDC

Dynamic C (Teso PC1620-PLC) controling LDC

我不熟悉任何形式的 C 编程。

我有一个 PLC(Teso PC1620)(使用兔子处理器)和一个 LCD 屏幕(矩阵轨道 LK204-7T-1U-USB-WB)。 我正在尝试使用 LCD 的内置水平 bar/graph 功能。

下面的代码有效,但我希望能够更改条的长度("bar" 数组中的第 6 个值)。 我用注释掉的代码而不是 "bar" 的静态常量进行了尝试,这似乎不起作用,并在 LCD 上给出了随机条。

什么会导致这种情况,是否有一种 easier/better 方法来分配 "bar" 数组。

#use "oempc16xxdrivers.elib"                            //Include the OEM pro-teso PC16XO driver library
#define DINBUFSIZE 31                                   //Defining the serial IN buffer size
#define DOUTBUFSIZE 31                                  //Defining the serial OUT buffer size

void main()
{

static const char clear[] = {254,88};         //Clear LCD command
static const char load[] = {254,104};             //Initialize horizontal bar
static const char bar[] = {254,124,1,1,0,54};  //Place horizontal bar(245,124) column,Row,Direction,Length

auto int percentage;
auto int rxKey;
//auto char bar[6];

IOInit();                                         //Initialises the PC1600 (PLC).
serDopen(19200L);                                 //Setting the baudrate of the serial port
serDrdFlush();                                    //Flushes the serial port D input buffer
serDwrFlush();                                        //Flushes the serial port D transmit buffer

serDwrite(clear,sizeof(clear));                //Clear LCD
serDwrite(load,sizeof(load));                  //Initialize horizontal bar

 //  bar[0] = 254;
 //  bar[1] = 124;
 //  bar[2] = 1;
 //  bar[3] = 1;
 //  bar[4] = 0;
 //  bar[5] = 54;

    for(;;)
    {
   rxKey = serDgetc();

   percentage = 10;
   //bar[5] = percentage;

    if (0x42 == rxKey)
    {
    serDwrite(bar,sizeof(bar));
    }
   }

serDclose ();
}

动态 c 版本 9.62

链接:

液晶: https://www.matrixorbital.com/advanced_search_result.php?keywords=LK204-7T-1U+usb&search.x=0&search.y=0

PLC: http://www.teso.com.au/pro-teso/PC1-Controllers/PC1600-Controller.aspx

您的代码似乎是正确的。

有没有可能你筹码很短space?这很可能是罪魁祸首,因为您添加了一个自动变量。

如果将 bar 定义为 global/static,请尝试它是否有效。