Compare commits

...

3 Commits

Author SHA1 Message Date
Stedd 7ab1ee525d Watchdog in the first Byte 2023-10-21 19:37:38 +02:00
Stedd 0991343a55 UDP Packets appear in wireshark and UDPlistener 2023-10-21 19:19:43 +02:00
Stedd c49c511d75 First UDP test
Copied code from UDP example
Added calls in setup and loop
Added Wifi config
2023-10-21 18:03:08 +02:00
3 changed files with 42 additions and 4 deletions

View File

@ -85,6 +85,9 @@ void setup() {
//Initialize PS3 controller connection //Initialize PS3 controller connection
Ps3.begin(_ps3Address); Ps3.begin(_ps3Address);
//Init UDP
UdpInit();
} }
void loop() { void loop() {
@ -106,13 +109,12 @@ void loop() {
// Plot // Plot
plot(); plot();
//Udp
UdpLoop();
//Save time for next cycle //Save time for next cycle
tLast = tNow; tLast = tNow;
//Delay //Delay
delay(5); delay(5);
//Test
} }

36
UDP.ino Normal file
View File

@ -0,0 +1,36 @@
const char* ssid = "CaveBot";
const char* password = "&nHM%D2!$]Qg[VUv";
#include "WiFi.h"
#include "AsyncUDP.h"
const IPAddress multicastIP = IPAddress(239, 1, 2, 3);
int port = 1234;
byte watchdog = 0;
AsyncUDP udp;
void UdpInit() {
//Serial.begin(115200);
ConnectToWiFi();
//udp.connect(multicastIP, port);
}
void UdpLoop() {
byte data[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
data[0] = watchdog++;
udp.writeTo(data, sizeof(data), multicastIP, port);
}
void ConnectToWiFi() {
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed");
while (1) {
delay(1000);
}
}
}

View File

@ -30,7 +30,7 @@ float OL_cont_out;
float ref_IL, act_IL, error_IL, IL_cont_out, iError_IL, IL_anti_windup; float ref_IL, act_IL, error_IL, IL_cont_out, iError_IL, IL_anti_windup;
float speedCmd1, speedCmd2; float speedCmd1, speedCmd2;
bool balancingOn = true; bool balancingOn = false;
//Matrices //Matrices
mtx_type motor_ang_vel[2][1]; mtx_type motor_ang_vel[2][1];