Go Down

Topic: using serial monitor sending data to Arduino Mega from a text file OSLOOMPROJECT (Read 3271 times) previous topic - next topic


Things you've said made me understand that I needed more in my answer which had...

The DoRow procedure you would write. It would lift the solenoids as necessary, and wait til weft (warp?) thread pulled through.
In "DoRow", that "wait til weft..." bit could be taken care of by looking at the signal that the "GoSwitch" provides.

Let's say that it goes HIGH when you press it. (It doesn't matter which way you wire it up... but you have to keep it clear in your mind as you write the software!!)

boGoSwitch would be programmed to return "true" when the switch was pressed.

AND... this is the bit I forgot, previously...

.... inside DoRow, there would be code to KEEP you IN the DoRow subroutine until boGoSwitch returned false again, i.e. until you released the button.

This is how you keep it from going at a silly speed. Give yourself time to "throw" the shuttle, comb or tuck the weft, etc, and then YOU tell the loom you are ready for what's lifted to go on to the next stage.

(Having "nothing lifted" stages between the "some things lifted" stages is no big deal at all.)


As for....

"The four "set-up" numbers and the four pattern code strings would be sent to the Arduino via the serial link, and stored in variables for reference and re-reference for as long as you wanted the loom to weave that pattern" How can I implement this?
The good news is: It CAN be done. And suggestions to date would all move you towards that ultimate goal.

First, though, get the loom working with just the program in the Arduino, "programmed" into it... and change the program, when you want to change what is woven.

I have already programmed the sketch with a software called Mblock that interfaces with the arduino shield, but it is not working with more than 8 servos and I have 16 in my loom.../quote]

Mblock MAY be a good starting point. Gives users the idea of what a program is, etc. Helps them by holding hand, making it hard to write something that just doesn't make sense.

But... as you pointed out... there will be limits.

The "raw" Arduino language IS a LITTLE strange at first... but I'd rather put my energies into something that, while strange, once mastered won't have limits. I will be able to do ANYTHING.

And it really isn't SO arcane, difficult, once you get the hang of it.


DO you need to say "everyone back to zero"?

If you say....

First.... 0015

Now.... 1500

.... as the loom "moves to" 1500, the second servo WILL GO to zero, won't it?

Hi tkbyd
yes I need all motors in resting position or "0" to tuck the weft back to meet closely the previous threads in the fabric
Let me update you with my progress I have download Realterm, a Serial Terminal software for Windows, and I am managing to sent two sequences to arduino  and can press "o" and all motors go resting
small steps


In "DoRow", that "wait til weft..." bit could be taken care of by looking at the signal that the "GoSwitch" provides.

Hi tkbyd
so this "DoRow" procedure looks interesting what we have agreed so far is that the following is OK:
int iRowsDone=0;
int iRowsAcross=2;//Number of motors

if boGoSwitch
bTmp=iRowsDone mod 04;// number of pattern to be repeated
if bTmp==0 then DoRow('0015');
if bTmp==1 then DoRow('0000');
if bTmp==2 then DoRow('1500');
if bTmp==3 then DoRow('0000');

//is this correct?
// if it is correct how can I introduce this in my original sketch


My original sketch was for three motors I have changed to 2 motors now so that you can show me how to mix both together I try myself and I get an error uploading it says boGoSwitch is not in the scope
My sketch for two motors would look like this

#include <Servo.h>
   String readString, servo1, servo2;
   Servo myservo1;  // create servo object to control a servo
   Servo myservo2;

   void setup() {
   myservo1.attach(2);  //the pin for the servo control

   void loop() {}

   void serialEvent() {
   while (Serial.available()) {
   if (Serial.available() >0) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString

   if (readString.length() >0) {
    Serial.println(readString); //see what was received

    // expect a string like 07002100 containing the two servo positions      
    servo1 = readString.substring(0, 2); //get the first three characters
    servo2 = readString.substring(2, 4); //get the next three characters
    Serial.println(servo1);  //print ot serial monitor to see results

    int n1; //declare as number  
    int n2;

    char carray1[4]; //magic needed to convert string to a number
    servo1.toCharArray(carray1, sizeof(carray1));
    n1 = atoi(carray1);

    char carray2[4];
    servo2.toCharArray(carray2, sizeof(carray2));
    n2 = atoi(carray2);
    myservo1.write(n1); //set servo position
tdbyd please be explicit, how can I mix the two together?


Sorry for delay... just can't devote a lot of time to this.

The boGoSwitch thing is a function you need to write for the program. But it is very straightforward...

Something like... (but will have to be adapted, depending on where you wired the "Go" button. I wrote following as if it were on digital line 7.... could "anywhere"... some pin you are not already using.

 boolean boGoSwitch(){       
    if (digitalRead(inPin)==HIGH) {
        return true;
        return false;

(You may want to swap the "true" and "false" around so that things make sense when you think in terms of what would "count" as "true" in your mind for the button. I.e. is pressed or not pressed the "go" signal, and which makes the digitalRead true? (Or change the HIGH to LOW... that will "flip" things, too.)

Thank you for starting with 2 motors. If done right, adding more, once 2 are working, won't be a big deal.

My version of the control software recently quoted by you is the program to control the loom without external inputs for pattern.... that's why how to marry hard to see. My version is only a starting point. Once that is working, adding the "change the patterns based on serial input" isn't too hard to add on.

Go Up