Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of 2-ComfileHMI_Modbus by
Revision 4:217cca9f2592, committed 2016-09-12
- Comitter:
- hyx2001
- Date:
- Mon Sep 12 09:31:11 2016 +0000
- Parent:
- 3:f234e151b888
- Commit message:
- ComfileHMI_Modbus
Changed in this revision
SimpleModbus.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/SimpleModbus.cpp Fri Sep 09 04:35:36 2016 +0000 +++ b/SimpleModbus.cpp Mon Sep 12 09:31:11 2016 +0000 @@ -43,7 +43,7 @@ device = Serial; startSimpleModbus(0, addr, Register, Coil); - ticker.attach_us(this, &comfileHMI::RunTime_HMI, 200); + ticker.attach_us(this, &comfileHMI::RunTime_HMI, 500); } /*******************************************************************************
--- a/main.cpp Fri Sep 09 04:35:36 2016 +0000 +++ b/main.cpp Mon Sep 12 09:31:11 2016 +0000 @@ -2,18 +2,26 @@ #include "mbed.h" #include "SimpleModbus.h" -static u8 MDcoil[100]={0,0,0,}; -static u16 MDregister[100]={100,200,300,400,}; +static u8 MDcoil[100]; +static u16 MDregister[100]; + +BusInOut LED(PC_0,PC_1,PC_2,PC_3,PC_4,PC_5,PC_6,PC_7); +BusInOut SWITCH(PB_0,PB_1,PB_2,PB_3,PA_9,PA_10,PA_11,PA_12); +AnalogIn ADIN0(PA_0); +AnalogIn ADIN1(PA_1); + int main() { StartModbus(PC_10, PC_11, 115200, 1, MDregister, MDcoil); + LED.output(); + SWITCH.input(); while (1) { - wait_ms(300); - MDregister[0]; - MDregister[1]; - MDregister[2]; - MDregister[3]; + wait_ms(50); + LED = MDcoil[0]; + MDcoil[1] = SWITCH; + MDregister[0] = ADIN0.read_u16(); + MDregister[1] = ADIN1.read_u16(); } }