ELEC240 Group Coursework ---------------------------------- C-Code for muscle controlled servo

Dependencies:   mbed

Committer:
BenRJG
Date:
Fri Jun 01 13:39:12 2018 +0000
Revision:
10:6b9c7857d57c
Parent:
9:a7085b7503d2
fixed adc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BenRJG 5:11489c0bd020 1 #include "FPGA.h"
BenRJG 5:11489c0bd020 2 #include "LCD.h"
BenRJG 5:11489c0bd020 3 #include "ADC.h"
BenRJG 5:11489c0bd020 4 float adval;
BenRJG 5:11489c0bd020 5 char adstr[32];
BenRJG 5:11489c0bd020 6 int err; //error variable used for debugging, trapping etc
BenRJG 0:87903e5535bc 7
BenRJG 0:87903e5535bc 8 int main (void)
BenRJG 2:b615682e3e4f 9 {
BenRJG 6:a61b01442f37 10 reset_board();
BenRJG 9:a7085b7503d2 11
BenRJG 2:b615682e3e4f 12 SPI_INIT();
BenRJG 8:462ce856429b 13 LCD_INIT();
BenRJG 5:11489c0bd020 14 /*err = 0;
BenRJG 5:11489c0bd020 15
BenRJG 5:11489c0bd020 16 adval =0.0f;
BenRJG 5:11489c0bd020 17
BenRJG 5:11489c0bd020 18 adval = read_adc();
BenRJG 5:11489c0bd020 19
BenRJG 5:11489c0bd020 20 sprintf(adstr,"%.3f",adval); //Store in an array string
BenRJG 5:11489c0bd020 21 lcd_locate(1,8); //and display on LCD
BenRJG 5:11489c0bd020 22 lcd_display(adstr); //
BenRJG 5:11489c0bd020 23
BenRJG 5:11489c0bd020 24 err = bar_graph(((adval/3.3f)*4095)/255); // 16*256 =4096 12 bit ADC!
BenRJG 5:11489c0bd020 25
BenRJG 5:11489c0bd020 26 if (err < 0){printf("Display Overload\r\n");}*/
BenRJG 5:11489c0bd020 27
BenRJG 1:acc66d3a1a1c 28 while(true) //Loop forever Knight Rider Display on FPGA
BenRJG 0:87903e5535bc 29 {
BenRJG 2:b615682e3e4f 30 SPI_TEST();
BenRJG 9:a7085b7503d2 31
BenRJG 9:a7085b7503d2 32 read_adc();
BenRJG 0:87903e5535bc 33 }
BenRJG 0:87903e5535bc 34 }