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: BEAR_Reciever Motor eeprom iSerial mbed
Fork of DogPID by
Revision 11:3dd92d1d542c, committed 2016-01-21
- Comitter:
- ParinyaT
- Date:
- Thu Jan 21 14:49:40 2016 +0000
- Parent:
- 10:3b3d6bc88677
- Child:
- 12:6b3b997dd7c2
- Commit message:
- update in main function
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| pinconfig.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Jan 16 12:06:59 2016 +0000
+++ b/main.cpp Thu Jan 21 14:49:40 2016 +0000
@@ -20,11 +20,13 @@
//*****************************************************/
// Global //
+Ticker Recieve;
//-- Communication --
Serial PC(D1,D0);
-ANDANTE_PROTOCOL_PACKET command;
Bear_Receiver com(Tx,Rx,115200);
-#define MY_ID 0x01
+int8_t MY_ID = 0x01;
+//-- Memorry --
+EEPROM memory(PB_4,PA_8,0);
//-- encoder --
int Upper_Position;
int Lower_Position;
@@ -134,7 +136,7 @@
}
//******************************************************/
-void CmdCheck(uint8_t *cmd)
+void CmdCheck(uint8_t *cmd,uint8_t ins)
{
switch(cmd[0]) {
case SET_MOTOR_UPPER_ANG : {
@@ -182,15 +184,38 @@
}
}
}
-
-
+/******************************************************/
+void Start_Up ()// load parameter from eeprom before start
+{
+ // wait for reciever
+ memory.read(0x00,MY_ID);
+ memory.read(0x04,Upper_SetPoint);
+ memory.read(0x08,Lower_SetPoint);
+ memory.read(0x10,U_Kc);
+ memory.read(0x14,U_Ti);
+ memory.read(0x18,U_Td);
+ memory.read(0x1c,L_Kc);
+ memory.read(0x20,L_Ti);
+ memory.read(0x24,L_Td);
+
+}
+/*******************************************************/
+void Rc ()
+{
+ uint8_t data_array[10];
+ int8_t ins;
+
+ com.ReceiveCommand(MY_ID,data_array);
+ CmdCheck(data_array,ins);
+}
+/*******************************************************/
int main()
{
- uint8_t id;
- uint8_t data_array[10];
+ Recieve.attach(&Rc,0.2);
+ Start_Up();
SET_UpperPID();
SET_LowerPID();
- /*
+
while(1) {
//Set Set_point
Up_PID.setSetPoint(Upper_SetPoint);
@@ -200,9 +225,9 @@
Move_Upper();
Move_Lower();
}
- */
+
- com.ReceiveCommand(id,data_array);
+ //com.ReceiveCommand(id,data_array);
}
--- a/pinconfig.h Sat Jan 16 12:06:59 2016 +0000 +++ b/pinconfig.h Thu Jan 21 14:49:40 2016 +0000 @@ -31,8 +31,8 @@ #define EncoderB PA_14 //serial comm -#define Tx PA_2 -#define Rx PA_3 +#define Tx PA_15 +#define Rx PB_7 #define Dir PB_5 #endif
