Starting with usercode
Getting to know code
The MicroPlex devices are very powerful and capable of many different operations. These operations can involve any combination of analog I/O, digital I/O, CAN messaging, and time based triggers. The most powerful way to combine all of these features is to use the backend or user code editing functionality.
To get started, right click on the module you would like to edit. Click on the "user_code.c" option. This will open the user_code.c file in your selected editor for ".c" files.
It is pretty difficult to read code without any kind of syntax highlighting or proper formatting. Editing C code with built in Windows Notepad will be a frustrating experience! There are many free and lightweight alternatives. One good option is Visual Studio Code.
Code Structure
The backend code of a MicroPlex device has many sections:
void usercode_init(void){}
void usercode(void){}
void user_can_message_receive(bios_can_msg_typ* msg){}
void user_int_timer_1ms(void){}
// The functions below are not designed to be used by the end user at the current time, do not delete!
void user_int_rx_sct(uint8_t module, uint8_t data){}
void user_int_port(uint8_t k){}
void user_int_adc(void){}
void user_int_stat_sci(void)
These functions will be described in depth on the next page.
The "front-end" code generated by logic created by triggers in the MicroPlex Lab workspace is injected into this backend file in several locations. These locations look similar to this:
//DO NOT DELETE THIS COMMENT
//--------------------------
//{{USERCODE}}
//--------------------------
If these comments are deleted, no front-end functionality will be included in the compiled file. Take care to not delete these comments.