Bonsoir,
J'essaie d'adapter mon programme fait pour l'Arduino Due pour le faire fonctionner sur la teensy 3.6.
Mais quand j'utilise la Teensy, Processing saccade alors qu'il fonctionnait parfaitement avec l'Arduino Due.
Avec la Due, le port dans Processing apparait comme ça
[1] "/dev/cu.usbmodem14201"
Avec la Teensy, le port dans Processing apparait comme ça
[1] "/dev/cu.usbmodem72864401"
Dans le setup du logiciel Teensyduino, j'ai réglé la vitesse du port série sur 250000 car j'envoie à 250000 bauds aussi depuis Processing.
Mon animation saccade mais toutefois, la LED "buit-in" de la Teensy fonctionne comme prévue quand je démarre Processing.
J'ai donc mal programmé un truc quelque part. Je mets mon programme en bas.
Aussi, je dois branché un module sur une liaison RX/TX de la Teensy et écrire sur cet autre port d'autres informations , comment pourrais-je trouver un exemple simple pour m'en servir? Merci
Merci pleinement.
A bien+
#include "TeensyStep.h" Stepper motor_1(1, 2); //DIR pin = 1 , STEP pin = 2, Stepper motor_2(3, 4); Stepper motor_3(5, 6); Stepper motor_4(7, 8); Stepper motor_5(9, 10); Stepper motor_6(11, 12); StepControl controller; int positionX, positionX1, positionX2, positionX3,positionX4,positionX5, positionX6, positionX7, positionX8, positionX9; // Receive with start- and end-markers combined with parsing const byte numChars = 200; char receivedChars[numChars]; char tempChars[numChars]; // temporary array for use when parsing // variables to hold the parsed data char messageFromPC[numChars] = {0}; //or {5} doesn't change anything int integerFromPC0 = 0; int integerFromPC1 = 0; int integerFromPC2 = 0; int integerFromPC3 = 0; int integerFromPC4 = 0; int integerFromPC5 = 0; int integerFromPC6 = 0; int integerFromPC7 = 0; int integerFromPC8 = 0; int integerFromPC9 = 0; int PC0= 0; int PC1= 0; int PC2= 0; int PC3= 0; int PC4= 0; int PC5= 0; int PC6= 0; int PC7= 0; int PC8= 0; int PC9= 0; int PCTer0= 0; int PCTer1= 0; int PCTer2= 0; int PCTer3= 0; int PCTer4= 0; int PCTer5= 0; int PCTer6= 0; int PCTer7= 0; int PCTer8= 0; int PCTer9= 0; int LoworderTrigger =0; int orderTrigger = 0; int orderCohesion = 0; float floatFromPC = 0.0; // no flat are used for the moment boolean newData = false; //============ const int ledPin = LED_BUILTIN;// the number of the LED pin void setup() { // set the digital pin as output: pinMode(ledPin, OUTPUT); Serial.begin (250000); // receive datas from Processing with the "Programming Port" // SerialUSB.begin (250000); // print datas to send it into the other serial port of the Arduino Due, the "Native Usb Port" //====Test if datas are printed into both serial of the Arduino Due /* SerialUSB.print ("A "); SerialUSB.println (-4); SerialUSB.print ("B "); SerialUSB.println (-3); SerialUSB.print ("C "); SerialUSB.println (-2); SerialUSB.print ("D "); SerialUSB.println (-1); SerialUSB.print ("E "); SerialUSB.println (-10); Serial.print ("A "); Serial.println (4); Serial.print ("B "); Serial.println (3); Serial.print ("C "); Serial.println (2); Serial.print ("D "); Serial.println (1); Serial.print ("E "); Serial.println (10); */ //====Initialise Pin Motor // setup the motors motor_1 .setMaxSpeed(3200) // steps/s .setAcceleration(1600); // steps/s^2 motor_2 .setMaxSpeed (3200) // steps/s .setAcceleration(2000); // steps/s^2 motor_3 //.setPullInSpeed(300) // steps/s currently deactivated... .setMaxSpeed( 3200) // steps/s .setAcceleration(2400) // steps/s^2 .setStepPinPolarity(LOW); // driver expects active low pulses motor_4 //.setPullInSpeed(300) // steps/s currently deactivated... .setMaxSpeed( 3200) // steps/s .setAcceleration(2800); // steps/s^2 motor_5 //.setPullInSpeed(300) // steps/s currently deactivated... .setMaxSpeed( 3200) // steps/s .setAcceleration(3200); // steps/s^2 } void loop() { recvWithStartEndMarkers(); // receive 33 datas from Processing 30 times/sec. if (newData == true) { strcpy(tempChars, receivedChars); // this temporary copy is necessary to protect the original data // because strtok() used in parseData() replaces the commas with \0 digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level) delay(100 ); // wait for a second digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second parseData(); // split the 33 data into its parts showPosition(); // These datas are used to control positions of 10 motors. Print them on the native port showPhazisScaled(); // Print datas on the native port showTrigBangWithRevolution(); // Print datas on the native port newData = false; } /* constexpr int spr = 16*200; // 3200 steps per revolution // lets shake for(int i = 0; i < 5; i++) { motor_1.setTargetRel(spr/4); // 1/4 revolution motor_4.setTargetRel(spr/4); // 1/4 revolution controller.move(motor_1, motor_4 ); motor_1.setTargetRel(-spr/4); motor_5.setTargetRel(-spr/4); controller.move(motor_1, motor_5); } delay(500); // move motor_1 to absolute position (10 revolutions from zero) // move motor_2 half a revolution forward // both motors will arrive their target positions at the same time motor_2.setTargetAbs(10*spr); motor_2.setTargetRel(spr/2); controller.move(motor_1, motor_2); // now move motor_2 together with motor_3 motor_1.setTargetRel(300); motor_2.setTargetRel(-800); controller.move(motor_2, motor_3); // move all motors back to their start positions motor_1.setTargetAbs(0); motor_2.setTargetAbs(0); motor_3.setTargetAbs(0); controller.move(motor_1, motor_2, motor_3); delay(1000); */ } void recvWithStartEndMarkers() { // receive 33 datas from Processing 30 times/sec. They are marked like that in Processing <12, -98, 34,... ,-340> static boolean recvInProgress = false; static byte ndx = 0; char startMarker = '<'; char endMarker = '>'; char rc; while (Serial.available() > 0 && newData == false) { rc = Serial.read(); if (recvInProgress == true) { if (rc != endMarker) { receivedChars[ndx] = rc; ndx++; if (ndx >= numChars) { ndx = numChars - 1; } } else { receivedChars[ndx] = '\0'; // terminate the string recvInProgress = false; ndx = 0; newData = true; } } else if (rc == startMarker) { recvInProgress = true; } } } //============ void parseData() { // split the 33 data into its parts char * strtokIndx; // this is used by strtok() as an index strtokIndx = strtok(tempChars,","); // get the first part - the string integerFromPC0 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC1 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC2 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC3 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC4 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC5 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC6 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC7 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC8 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off integerFromPC9 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC0 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC1 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC2 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC3 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC4 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC5 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC6 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC7 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC8 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PC9 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer0 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer1 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer2 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer3 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer4 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer5 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer6 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer7 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer8 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off PCTer9 = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off LoworderTrigger = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off orderTrigger = atoi(strtokIndx); // convert this part to an integer strtokIndx = strtok(NULL, ","); // this continues where the previous call left off orderCohesion = atoi(strtokIndx); // convert this part to an integer } //============
A