fdserial between two propeller 'flip' modules.; ABANDONED

bbrienbbrien Posts: 264
edited 2020-07-09 - 03:47:49 in General Discussion
I having lots of problems with fdserial with two flips. I am using propeller C. Flip1 is running a program which uses 5 switches, 1 for speed and four for directions. The final output sends four bytes(0-255) by means of
fdserial_txChar(RmotorPin);
fdserial_txChar(RdirPin);
fdserial_txChar(DmotorPin);
fdserial_txChar(DdirPin);
now my understanding is that the commands send a byte to the transmit buffer. the next question is do I setup the buffers in the (MAIN) or not.When the second flip reads the input (rxpin) nothing happens.Sending the files. Can you please check them. I think I may need a receive buffer.

Comments

  • I am a Spin guy, but I know fdserial buffers are maintained by the object. You don't have to account for them. The default buffers on the original fdserial object are a bit short at only 16 bytes, but there are enhanced versions that provide for increasing the buffer size. If you are receiving nothing, the serial object is probably not your actual problem.
  • First of all the LX 50 Ver 3 program will not work. Wrong use of fdserial_rxCheck.

    Based on the master program do you have pin 3 (TX) on master wired to pin 0 (RX) on slave flip wired together. Data send by master program will be send and received to an internal buffer on the receiving flip. No buffers required.

    Mike
  • Also if you are not receiving any data on the flip you may have damaged that pin when it was connected to the Arduino as pulling this pin to 5 volts may have damaged it.

    Mike
  • Maybe you could build a simple test program.

    On the master flip set pin 3 high and on the slave flip read the state of pin 0. If you see it does return a high value then it worked.
    Now change the master program and set pin 3 low and see if you can see a low value on pin 0. If this all works then serial should work as well.

    Master program test
    #include "simpletools.h"
    
    int main()
    {
    
     
      while(1)
      {
        high(3);
        pause(5000);  //<-- pause 5 seconds
        low(3);
        pause(5000);
      }  
    }
    

    Slave program test
    #include "simpletools.h"
    
    int i;
    
    int main()
    {
     
      while(1)
      {
        i = input(0);
        print("Pin 0 State: %d\n", i);
        pause(1000);
      }  
    }
    

    The Slave program will output the state of pin 0 every second on the terminal screen.

    Mike
  • 1; no the masterflip has rx = 0 and tx = 1
    2; I have two new flips,should not have any damages unless factory defects.
    3; will try the new tests
  • I just look at the master code and it's using 2 and 3.
    #define rx 2
    #define tx 3
    
      fd = fdserial_open(rx, tx, FDSERIAL_MODE_NONE, 115200);
    
    

    Mike
  • 1; no the master flip has rx = 0 and tx = 1. I must have sent a different file
  • Tried the sketches and the print is pin 0 state 0 . how does master work without any initialisers.
  • The propeller is a simpler processor and doesn't have any states that need to be set. Only input or output state which is set automatically by the high and low function used in the program.

    The Arduino code has to worry about Input, Output, Pull up, Pull down, Analog, Digital as some pins have special functions and can be connected to internal timers.

    There are two programs. One to run on the master and the other to run on the slave flip. The master will set the pin state that is wired to the slave and the slave program will tell you what the state of that pin is. If everything is wired up correctly the state of the pin will change as the master program runs. Sort of like serial data running in slow motion.

    Mike

  • I set connect pin 3 of master to pin 0 of slave and I have 0 or 1 for pin state now, what next ?
  • Now we know the pins and wiring are correct and we can go back to the original code and see if we can get serial to work or we could build a master/slave serial program and see if we can get that to work.

    Your choice.

    Mike
  • My master program looks like it works ok. The print output values and the 0 or 1 states. but I cant get a print on the buffers or even the "value" in the print in the slave.
  • Need to make sure you are using the correct pins for tx and rx.

    Mike
  • In the programs LX50A(master and the program LX50 ver 3 rx = 0 and tx = 1.
  • bbrien wrote: »
    I set connect pin 3 of master to pin 0 of slave and I have 0 or 1 for pin state now, what next ?

    So pin 3 on master would be your transmit(tx) pin 3 and pin 0 on the slave would be the receive(rx).

    Mike
  • As you suggested. Lets do some more testing.
  • Here are some test programs. One is labeled "Master" and the other "Slave" as before.

    These program will run two test. The first is as before setting a pin high and then low.

    The second test actually send a character using serial.

    In the program is a define for TEST which can be set to 0 for test 1 or 1 for test 2. Each program will display what it is doing.

    MASTER:
    #include "simpletools.h"
    #include "fdserial.h"
    
    void Test1(void);
    void Test2(void);
    
    // Change the value after TEST to 0 or 1
    #define Tx 0
    #define Rx 1
    #define TEST 0
    
    fdserial *fd;
    int i;
    
    int main()
    {
      
      if (TEST == 0)
        Test1();
      
      if (TEST == 1)
        Test2();
     
      while(1)
      {
        print("Test %d\n", TEST);
        pause(1000);
      }  
    }
    
    void Test1()
    {
      while (1)
      {
        low(Tx);
        print("Pin: %d => High\n", Tx);
        pause(1000);
        high(Tx);
        print("Pin %d => Low\n", Tx);
        pause(1000);
      }
    }
    
    void Test2()
    {
      fd = fdserial_open(Rx, Tx, FDSERIAL_MODE_NONE, 115200);
      
      while (1)
      {
        fdserial_txChar(fd, '1');
        print("Pin: %d => 1\n", Tx);
        pause(1000);
        fdserial_txChar(fd, '0');
        print("Pin: %d => 0\n", Tx);
        pause(1000);
      }
      fdserial_close(fd);
    }
    

    SLAVE
    #include "simpletools.h"
    #include "fdserial.h"
    
    
    void Test1(void);
    void Test2(void);
    
    // Change value after TEST to 0 or 1
    #define Rx 0
    #define Tx 1
    #define TEST 0
    
    fdserial *fd;
    int i;
    
    int main()
    {
    
      if (TEST == 0)
        Test1();
      
      if (TEST == 1)
        Test2();
     
      while(1)
      {
        print("TEST: %d\n", TEST);
        pause(1000);
      }  
    }
    
    void Test1()
    {
      while (1)
      {
        i = input(Rx);
        print("Pin: %d => %d\n", Rx, i);
        pause(1000);
      }
    }
    
    void Test2()
    {
      fd = fdserial_open(Rx, Tx, FDSERIAL_MODE_NONE, 115200);
      
      while (1)
      {
        i = fdserial_rxCount(fd);
        if (i > 0)
        {
          i = fdserial_rxChar(fd);
          print("pin: %d => %d \n", Rx, i);
        }
      }
      fdserial_close(fd);
    }
    

    Mike
  • Files loaded and will try them real soon. Thanks.
  • bbrienbbrien Posts: 264
    edited 2020-06-07 - 19:29:33
    Print output 0 changing to 1 and back to 0 on both lines. Now can we get a pulse going from master to slave outputting on pin #17. pulse between 50 to 150/255.
Sign In or Register to comment.