This is an old revision of the document!
This project illustrates how to use a ComfileHMI to monitor and control an FADUINO's digital inputs and outputs.
Download ComfileHMI Project
Download FADUINO Source Code
#include "SimpleModbusRtu_mega2560.h" uint16_t au16data[16]; uint8_t au8data[10]; void setup() { int i; for(i=22; i<38; i++){ pinMode(i, INPUT); } // 22 ~ 37 Inputs for(i=38; i<52; i++){ pinMode(i, OUTPUT); } // 38 ~ 51 Outputs Serial.begin(9600); usart1init(57600); // 9600, 19200, 38400, 57600 , Serial channel1 startSimpleModbus(1, au16data, au8data); // slave address, register, coil } void loop() { int n; for(n=0; n<8; n++){ bitWrite(au8data[0] ,n, digitalRead(n+22)) ;} //Input for(n=0; n<8; n++){ bitWrite(au8data[1], n, digitalRead(n+30)) ;} for(n=0; n<8; n++){ digitalWrite(38+n, bitRead(au8data[2], n)) ;} // Output for(n=0; n<8; n++){ digitalWrite(46+n, bitRead(au8data[3], n)) ;} }
This project illustrates how to use a ComfileHMI to monitor and control an FADUINO's analog inputs and outputs.