added real stuff maybe wrong place to commit (sorry)
This commit is contained in:
parent
9193f1244e
commit
ba4616e152
|
@ -1,5 +1,57 @@
|
|||
#include <Arduino.h>
|
||||
#include "ardusss7.h"
|
||||
#include "ss7content.h"
|
||||
#include <AccelStepper.h>
|
||||
|
||||
#define ENDSTOP1 6
|
||||
#define S1_ENABLE 2
|
||||
#define MICROSTEP A5
|
||||
|
||||
#define MAXPOSITIONS 6
|
||||
#define DISTANCE 1000
|
||||
uint16_t position[MAXPOSITIONS]{60,1060,2060,3085,4085,5085};
|
||||
|
||||
#define ID 3
|
||||
|
||||
void init_stepper(){
|
||||
pinMode(ENDSTOP1, INPUT_PULLUP);
|
||||
|
||||
pinMode(S1_ENABLE, OUTPUT); //ENABLE STEPPER
|
||||
digitalWrite(S1_ENABLE, LOW);
|
||||
|
||||
pinMode(MICROSTEP, OUTPUT);
|
||||
digitalWrite(MICROSTEP, LOW);
|
||||
|
||||
stepper.setAcceleration(1500);
|
||||
stepper.setMaxSpeed(3000);
|
||||
|
||||
}
|
||||
|
||||
void home(){
|
||||
if(!digitalRead(ENDSTOP1)){
|
||||
stepper.runToNewPosition(100);
|
||||
}
|
||||
uint16_t stepout = 0;
|
||||
while(digitalRead(ENDSTOP1 && (stepout <= (DISTANCE*MAXPOSITIONS)))){
|
||||
stepper.moveTo(-10);
|
||||
stepout += 10;
|
||||
stepper.run();
|
||||
stepper.setCurrentPosition(0);
|
||||
// stepper.runToNewPosition(0);
|
||||
//stepper.run();
|
||||
digitalWrite(11,LOW); //Kein plan
|
||||
}
|
||||
}
|
||||
|
||||
void select(uint8_t tube){
|
||||
if(tube>0 && tube <= MAXPOSITIONS){
|
||||
stepper.runToNewPosition(position(tube));
|
||||
}
|
||||
else{
|
||||
home();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
|
@ -28,25 +80,25 @@ void loop() {
|
|||
|
||||
|
||||
while(1) {
|
||||
Serial.println("Waiting to send");
|
||||
while(!SSS7.canSend());
|
||||
Serial.println("Sending ...");
|
||||
SSS7.send(msg);
|
||||
while(!SSS7.canSend());
|
||||
//Serial.println("Waiting to send");
|
||||
//while(!SSS7.canSend());
|
||||
//Serial.println("Sending ...");
|
||||
//SSS7.send(msg);
|
||||
//while(!SSS7.canSend());
|
||||
//Serial.println("Finished Sending");
|
||||
if(SSS7.sendFailed()) {
|
||||
Serial.println("Send failed");
|
||||
}
|
||||
|
||||
|
||||
//if(SSS7.sendFailed()) {
|
||||
// Serial.println("Send failed");
|
||||
// }
|
||||
if(SSS7.hasReceived()) {
|
||||
uint8_t msg1[SSS7_PAYLOAD_SIZE];
|
||||
SSS7.getReceived(msg1);
|
||||
Serial.print("Got data:");
|
||||
Serial.println((char*)msg1);
|
||||
if((msg1[0]==MSG_CONNECT)&&(msg[2]==ID)){
|
||||
select(msg1[3]);
|
||||
}
|
||||
}
|
||||
|
||||
_delay_ms(1000);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
|
||||
#ifndef ss7content_h
|
||||
#define ss7content_h
|
||||
|
||||
//MSG ID
|
||||
|
||||
#define MSG_DETECT 0x00
|
||||
#define MSG_CONNECT 0x01
|
||||
#define MSG_CONNECTED 0x02
|
||||
#define MSG_REQUEST_DIRECT 0x03
|
||||
#define MSG_REQUEST_BARCODE 0x04
|
||||
#define MSG_CONFIRM_REQUEST 0x05
|
||||
#define MSG_BEGIN_TRANSFER 0x06
|
||||
#define MSG_BARCODE_DETECT 0x07
|
||||
|
||||
|
||||
//STATION
|
||||
|
||||
#define ID_READER 0x00
|
||||
#define ID_CENTRAL 0x01
|
||||
|
||||
#define ID_ROUTER1 0x03
|
||||
|
||||
#define ID_VAC 0xFF
|
||||
|
||||
|
||||
#endif /* ss7content_h */
|
Loading…
Reference in New Issue