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.
main.cpp
- Committer:
- seoirsem
- Date:
- 2019-08-12
- Revision:
- 3:5d99b45d534a
- Parent:
- 2:b1f6e4f51d06
- Child:
- 4:09c9778f26aa
File content as of revision 3:5d99b45d534a:
#include "mbed.h"
#include "MODSERIAL.h"
#include "FastPWM.h"
#include "math.h"
/*------------------------------------------------------------------------------
Codebase for T99004 Demo Control Board Rev A Firmware
Date: 10/07/2018
Author: AS7
------------------------------------------------------------------------------*/
#define ALL_CH 15 //value of convst bus to read all chanels simultaneosly
#define TICK_PERIOD 1000// Tick cylcle
MODSERIAL pc(PA_9, PA_10, 512); //mcu TX, RX, 512 byte TX and RX buffers
//indicator LEDs
DigitalOut hb_led(PC_13); //Green
DigitalOut led_0(PC_4); //Red
DigitalOut led_1(PC_5); //Green
//User buttons
DigitalIn user_0(PB_0);
DigitalIn user_1(PB_1);
//Heater Control
FastPWM drive_1(PC_9);
FastPWM drive_2(PC_8);
FastPWM guard_1(PC_7);
FastPWM guard_2(PC_6);
Timer timer;
int main()
{
// Initialsation
pc.baud(115200);
//led_1 = drive_1; //tie led 1 and heater 1 outputs together so LED shows while heater is on (initial debug purposes only)
timer.start(); //Start the timer
//Initialise drive periods
drive_1.prescaler(1);
guard_1.prescaler(1);
drive_2.prescaler(1);
guard_2.prescaler(1);
drive_1.period_ticks(TICK_PERIOD);
guard_1.period_ticks(TICK_PERIOD);
drive_2.period_ticks(TICK_PERIOD);
guard_2.period_ticks(TICK_PERIOD);
//while (user_1==0); //waits for a button press before starting the programme
float ratio_guard = 21.0/82;
int main_tick_1 = 150;
int guard_tick_1 = floor(main_tick_1 * ratio_guard);
int main_tick_2 = 0;
int guard_tick_2 = floor(main_tick_2 * ratio_guard);
while(1){
drive_1.pulsewidth_ticks(main_tick_1);
guard_1.pulsewidth_ticks(guard_tick_1);
drive_2.pulsewidth_ticks(main_tick_2);
guard_2.pulsewidth_ticks(guard_tick_2);
wait(2);
//heater_2.output();
//pc.printf("%d, %f, %f\n",tic_guard,j,ratio_guard);
}
}