SamanthaDawsonBanks / MCOMP_Team_Project_2017-2018

MIT License
6 stars 1 forks source link

Drive and Sense methods #33

Closed SamanthaDawsonBanks closed 6 years ago

SamanthaDawsonBanks commented 6 years ago

both the driver and the sense methods are currently on my list but I am behind on my work due to not allocating enough (any) time to the data structures. who fancies taking secondary on these methods?

RyanShoobert commented 6 years ago

I'm a little behind on my bits as well but I'll be happy to help once I've caught up.

SamanthaDawsonBanks commented 6 years ago

that would be great, anyone else got time to spare?

stevempope commented 6 years ago

More than happy to help with these bits.

Are you looking for the Arduino side or Java side? Or both?

SamanthaDawsonBanks commented 6 years ago

C/Java some and some mostly C but also the facade stuff in J land

HarryWJackson1996 commented 6 years ago

I don't mind giving it a look as well

SamanthaDawsonBanks commented 6 years ago

coolio ty all, sorry for falling behind

SamanthaDawsonBanks commented 6 years ago

reopened to link in with MS1

SamanthaDawsonBanks commented 6 years ago

info about motors for drive https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/using-stepper-motors

SamanthaDawsonBanks commented 6 years ago

info about LiDAR sensor https://xv11hacking.wikispaces.com/LIDAR+Sensor and https://www.impulseadventure.com/elec/robot-lidar-neato-xv11.html

looking a the power specifications for the LiDAR we should really use a closed feedback loop to control PWM on some pins for speed control vs straight voltage.

this is good as it removed another power chain, but does require some more sensing and control code on the sense system...

"The motor can be powered at 3.3V continuous ( ~60mA ) in open loop, which will produce a turn rate of around 240rpm on a clean and recent sensor. Hair and dust can however create friction that will lower the rotation speed. Using the turn rate information contained in the data, a closed loop control can be implemented, and is recommended."

"Each packet is organized as follows: [Data 0] [Data 1] [Data 2] [Data 3] where: ... ... speed is a two-byte information, little-endian. It represents the speed, in 64th of RPM (aka value in RPM represented in fixed point, with 6 bits used for the decimal part)."

SamanthaDawsonBanks commented 6 years ago

Speed should be 180-320 rpm for good data 240 is 3.3v on a 'clean' sensor but does drift

the simplest way to do this is to use AnalogWrite: https://www.arduino.cc/en/Tutorial/PWM start it at AnalogWrite(167) //66% of 5v ≈ 3.3v then on each sense: if (speed < 220) {inc pwm} if (speed > 260) {dec pwm}

comments?

SamanthaDawsonBanks commented 6 years ago

also remember that there are some flowcharts that define some of these bits in OD/docs/diagrams/flowcharts

SamanthaDawsonBanks commented 6 years ago

I have a branch checked-out for the main Arduino Setup and Loop stuff, I will be assuming the following sigs: <(ϴ,D)1...(ϴ,D)360>LiDARSense() <(X,Y)1...(X,Y)360>LiDARToXY(<(ϴ,D)1...(ϴ,D)360>) (X,Y)Drive(X,Y) does that work for everyone?

stevempope commented 6 years ago

Works for me!

SamanthaDawsonBanks commented 6 years ago

re-reading the arduino and LiDAR spec we can't run it straight off the PWM as the arduino can only supply 40mA (peak) 30mA sustained and the LiDAR often needs 60+mA so we will need some for of power controller

stevempope commented 6 years ago

Drive is now complete.

CFuterman commented 6 years ago

From the meeting that we had on Tuesday, we established that all that was left to close this issue was the sense flow charts that needed updating. Can progress on this front be posted here please.

SamanthaDawsonBanks commented 6 years ago

that was a miscommunication; we have the flowchart, and the logic, but we need to pull the code together from the 4 libraries we are referencing there is a basic set (from GH/getSurreal/XV_Lidar_Controller) on GH in the LiDAR_Test branch but when i tested it on the hardware Thursday 5th it didn't seem to work right so I will loop Steve in once he is free

SamanthaDawsonBanks commented 6 years ago

code planned for tuesday

SamanthaDawsonBanks commented 6 years ago

/*

//------------------------------------Includes------------------------------------- // any required libraries

include "Arduino.h"

//-----------------------------------Definitions----------------------------------- // eg. #define RED 13 // or, #define ON HIGH

define CONSOLE Serial //usb console

define CHANNEL Serial1 //board to board TX18 RX19

//------------------------Function prototypes (signatures)------------------------- // listing signatures assists in debugging! //eg. int readInt(String prompt); // description & warnings

//--------------------------------Global Variables--------------------------------- // Remember you ONLY have 2k system RAM // eg. boolean personWaiting = true;

//----------------------------Global Volatile Variables---------------------------- // Volatile variables used by interrupts // eg. volatile boolean personWaiting = true; // volatile interrupt

//--------------------------------------Setup-------------------------------------- //The setup function is called once at startup of the sketch // Remember to "Serial.begin(baud);" // and Initialise I/O pins // eg. pinMode(RED, OUTPUT);

void setup() { // TODO Add your initialisation code here CONSOLE.begin(115200); CHANNEL.begin(115200); // rate limited 300 baud for stability } //End Setup

//-----------------------------Functions / Subroutines-----------------------------

//---------------------------ASM Functions / Subroutines---------------------------

//--------------------------------Interrupt Handlers-------------------------------

//-----------------------------------Loop / Main----------------------------------- // The loop function is called in an endless loop

void loop() { // TODO Add your repeated code here

if (CHANNEL.available()) { CONSOLE.println(CHANNEL.read(),HEX); CONSOLE.write(CHANNEL.read()); //if there is something in the channel buffer read it, print it to the console, and loop }

if (CONSOLE.available()) { CHANNEL.write(CONSOLE.read()); //if there is something in the console buffer read it, send it to the channel, and loop }

} // End Loop

stevempope commented 6 years ago

Update on progress, we have identified how to pick the head of a packet out and reverse the little endian format to pull out the rpm data. We can now apply this logic to the rest of the bytes in the packets and we should be able to pull out some sensor data.

SamanthaDawsonBanks commented 6 years ago

Would it be useful if we put together a 'packet' object and/or a return object?

stevempope commented 6 years ago

For the moment I am going to work on handing back the pointer to an array, but it's certainly something we should look at when I bring together the final "sense" method

stevempope commented 6 years ago

Both Drive and Sense are now complete and ready to have their output turned into Serial-ready content as per #197 Pipe object.