Main Program
Dependencies: mbed AQM1602 HMC6352 PID
setting/main.h@42:02aaa806d929, 2016-02-04 (annotated)
- Committer:
- lilac0112_1
- Date:
- Thu Feb 04 20:45:41 2016 +0000
- Revision:
- 42:02aaa806d929
- Parent:
- 40:f68474b1d5e7
InterruptForce are added and so on.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lilac0112_1 | 14:6f214ea5722e | 1 | #ifndef _MAIN_H_ |
lilac0112_1 | 14:6f214ea5722e | 2 | #define _MAIN_H_ |
lilac0112_1 | 14:6f214ea5722e | 3 | |
lilac0112_1 | 14:6f214ea5722e | 4 | #include "def.h" |
lilac0112_1 | 14:6f214ea5722e | 5 | |
lilac0112_1 | 16:6900f47fa0b5 | 6 | //pc(Computer) |
lilac0112_1 | 16:6900f47fa0b5 | 7 | RawSerial pc(monitor_tx, monitor_rx); |
lilac0112_1 | 16:6900f47fa0b5 | 8 | //led(main) |
lilac0112_1 | 16:6900f47fa0b5 | 9 | DigitalOut LED[4]={led1, led2, led3, led4}; |
lilac0112_1 | 16:6900f47fa0b5 | 10 | //line(bottom) |
lilac0112_1 | 18:97eba56f82e4 | 11 | BusOut LineSignalHolder(lineInA, lineInB, lineInC); |
lilac0112_1 | 21:d69a8f3c76e1 | 12 | BusIn RawLineSignal(lineA2, lineB2, lineC2); |
lilac0112_1 | 21:d69a8f3c76e1 | 13 | BusIn HeldLineSignal(lineA1, lineB1, lineC1); |
lilac0112_1 | 21:d69a8f3c76e1 | 14 | InterruptIn Line[3]={lineA2, lineB2, lineC2}; |
lilac0112_1 | 16:6900f47fa0b5 | 15 | //ballcheck(bottom) |
lilac0112_1 | 16:6900f47fa0b5 | 16 | DigitalIn BallChecker(ballcheck); |
lilac0112_1 | 16:6900f47fa0b5 | 17 | //debug_switch(debug_board) |
lilac0112_1 | 17:61edad76efd7 | 18 | DigitalIn Sw[4] = {selectsw1, selectsw2, debugsw1, debugsw2}; |
lilac0112_1 | 16:6900f47fa0b5 | 19 | //motor(main) |
lilac0112_1 | 16:6900f47fa0b5 | 20 | Serial motor(motor_tx, motor_rx); |
lilac0112_1 | 16:6900f47fa0b5 | 21 | //spi(main) |
lilac0112_1 | 16:6900f47fa0b5 | 22 | SPI spi(SPI_mosi, SPI_miso, SPI_slck); |
lilac0112_1 | 16:6900f47fa0b5 | 23 | DigitalOut spi_ss[4]={SPI_ss_sd, SPI_ss_sonic, SPI_ss_color, SPI_ss_ir}; |
lilac0112_1 | 16:6900f47fa0b5 | 24 | //bluetooth(debug_board) |
lilac0112_1 | 16:6900f47fa0b5 | 25 | RawSerial RN42(blue_rxd, blue_txd); |
lilac0112_1 | 16:6900f47fa0b5 | 26 | DigitalOut RN42_Reset(blue_reset); |
lilac0112_1 | 16:6900f47fa0b5 | 27 | //lcd(debug_board) |
lilac0112_1 | 16:6900f47fa0b5 | 28 | AQM1602 Lcd(lcd_sda, lcd_scl); |
lilac0112_1 | 21:d69a8f3c76e1 | 29 | //cmps(debug_board) |
lilac0112_1 | 21:d69a8f3c76e1 | 30 | HMC6352 hmc(sens_sda, sens_scl); |
lilac0112_1 | 16:6900f47fa0b5 | 31 | //mouse(bottom) |
lilac0112_1 | 16:6900f47fa0b5 | 32 | adns_9800 mouse_sensor(mouse_mosi, mouse_miso, mouse_slck, mouse_ss); |
lilac0112_1 | 16:6900f47fa0b5 | 33 | //solenoid(bottom) |
lilac0112_1 | 16:6900f47fa0b5 | 34 | DigitalOut kicker(solenoid); |
lilac0112_1 | 16:6900f47fa0b5 | 35 | |
lilac0112_1 | 16:6900f47fa0b5 | 36 | //Serial for motors |
lilac0112_1 | 16:6900f47fa0b5 | 37 | int speed[4]={0}; |
lilac0112_1 | 16:6900f47fa0b5 | 38 | string StringFIN; |
lilac0112_1 | 16:6900f47fa0b5 | 39 | //PID |
lilac0112_1 | 16:6900f47fa0b5 | 40 | PID pid(P_GAIN,I_GAIN,D_GAIN, RATE); |
lilac0112_1 | 16:6900f47fa0b5 | 41 | Ticker pidupdate; |
lilac0112_1 | 16:6900f47fa0b5 | 42 | //for Serial |
lilac0112_1 | 14:6f214ea5722e | 43 | volatile uint8_t INdata[DATA_NUM]={0}, EXdata[DATA_NUM]={0}; |
lilac0112_1 | 16:6900f47fa0b5 | 44 | //for DataSet |
lilac0112_1 | 14:6f214ea5722e | 45 | Record data; |
lilac0112_1 | 19:342da3a5a474 | 46 | //for transition |
lilac0112_1 | 19:342da3a5a474 | 47 | Ticker Sw_ticker; |
lilac0112_1 | 19:342da3a5a474 | 48 | Timeout button; |
lilac0112_1 | 19:342da3a5a474 | 49 | bool state[4]={0,0,0,0}; |
lilac0112_1 | 19:342da3a5a474 | 50 | uint8_t statesum=0, last_statesum=0; |
lilac0112_1 | 16:6900f47fa0b5 | 51 | // for Time |
lilac0112_1 | 24:9fb74ea3c25d | 52 | Ticker Motor_ticker; |
lilac0112_1 | 24:9fb74ea3c25d | 53 | Ticker Line_ticker; |
lilac0112_1 | 24:9fb74ea3c25d | 54 | Ticker Ir_ticker; |
lilac0112_1 | 42:02aaa806d929 | 55 | Ticker Ping_ticker; |
lilac0112_1 | 24:9fb74ea3c25d | 56 | Ticker Solenoid_ticker; |
lilac0112_1 | 42:02aaa806d929 | 57 | Ticker Hmc_ticker; |
lilac0112_1 | 24:9fb74ea3c25d | 58 | Timeout Solenoid_timeout; |
lilac0112_1 | 40:f68474b1d5e7 | 59 | Timeout Line_timeout[3]; |
lilac0112_1 | 14:6f214ea5722e | 60 | Ticker Duty[DUTY_NUM]; |
lilac0112_1 | 14:6f214ea5722e | 61 | Timeout Stp; |
lilac0112_1 | 14:6f214ea5722e | 62 | double dutycycle[DUTY_NUM] ={//[s] |
lilac0112_1 | 14:6f214ea5722e | 63 | 0.2 |
lilac0112_1 | 14:6f214ea5722e | 64 | }; |
lilac0112_1 | 14:6f214ea5722e | 65 | |
lilac0112_1 | 14:6f214ea5722e | 66 | #endif /*_MAIN_H_*/ |