Why is pin 31 always on?

I want it to blink when there's data coming over the USB serial connection.
#include "simpletools.h"

int main() 
{
  low(27); 
  while(1)
  {
    set_output(27,input(31));
  }  
}

Comments

  • 11 Comments sorted by Date Added Votes
  • I would normally try to avoid using pins 30 & 31 as they are often mainly used for communicating with host programming using PropPlugs.

    (From manual)
    P28 - I2C SCL connection to optional, external EEPROM.
    P29 - I2C SDA connection to optional, external EEPROM.
    P30 - Serial Tx to host.
    P31 - Serial Rx from host.

    Kenichi
  • Google "UART idle state" and compare that to what you see on P31



    Beau Schwabe -- Submicron Forensic Engineer
    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

    Seriously at this point in the game the ship has sailed and "I have no expectations" <- said someone we know
  • Take things one step at a time. Start by checking the input propeller. Make a routine to count pulses on that input and connect that line high and low a few times and verify that it counts. Now you know that your input is working. Now connect the output propeller up and make sure its counting pulses. Then you know the hardware is working right. From that point,you can write your code to do whatever it is you intend. As was noted,dont use P28-P31 unless you know that you SHOULD be using them for some reason. The rule of thumb for those lines is, if you have to ask if you should or should not, then the answer is probably that you should not.
  • I don't understand the responses to this question. The OP is not trying to use pin 31 for anything other than its normal function of supporting a serial connection. He is just trying to monitor it and display its state on another pin with an LED connected. He is expecting that LED to flicker when serial data is sent to pin 31. Now maybe this won't work because pin 31 is almost always high since that is the idle state of a UART connection but that doesn't mean he is misusing pin 31. In fact, he *has* stayed away from 28-31 as evidenced by the fact that his LED is on pin 27.
  • David Betz wrote: »
    I don't understand the responses to this question. The OP is not trying to use pin 31 for anything other than its normal function of supporting a serial connection. He is just trying to monitor it and display its state on another pin with an LED connected. He is expecting that LED to flicker when serial data is sent to pin 31. Now maybe this won't work because pin 31 is almost always high since that is the idle state of a UART connection but that doesn't mean he is misusing pin 31. In fact, he *has* stayed away from 28-31 as evidenced by the fact that his LED is on pin 27.

    If that's the case, then just make the LED on, if pin 31 is low.
    You can see a short flash ON on a normally dark LED, but you never see a short OFF on a normaly bright LED.

    Andy

  • Ariba wrote: »
    David Betz wrote: »
    I don't understand the responses to this question. The OP is not trying to use pin 31 for anything other than its normal function of supporting a serial connection. He is just trying to monitor it and display its state on another pin with an LED connected. He is expecting that LED to flicker when serial data is sent to pin 31. Now maybe this won't work because pin 31 is almost always high since that is the idle state of a UART connection but that doesn't mean he is misusing pin 31. In fact, he *has* stayed away from 28-31 as evidenced by the fact that his LED is on pin 27.

    If that's the case, then just make the LED on, if pin 31 is low.
    You can see a short flash ON on a normally dark LED, but you never see a short OFF on a normaly bright LED.

    Andy
    Good idea!

  • I hoping I could directly forward the serial connection to an lcd. Maybe I should have said that in the first post.
  • just connect the LCD to pin31 without forwarding anything?

    you can connect multiple things to one pin, usually it is like one output can drive around 10 inputs?

    Mike
    I am just another Code Monkey.
    A determined coder can write COBOL programs in any language. -- Author unknown.
    Press any key to continue, any other key to quit

    The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this post are to be interpreted as described in RFC 2119.
  • brandanbrandan Posts: 52
    edited December 1 Vote Up0Vote Down
    I have an lcd on pin 0. I want to control an lcd screen with my code on my laptop. My current code is kinda slow, its only like 60 bytes per second. It uses an ack byte. I tried it without an ack byte, but the message gets corrupted or doesn't send.

    Here's my current code:
    import serial
    import time
    from coinmarketcap import Market
    coinmarketcap = Market()
    ser = serial.Serial('/dev/ttyUSB0', 115200, timeout =1)
    def lcd(s):
    	sa = str(bytearray([17,22,12])) + str(s) + '\0'
    	for c in str(sa):
    		ser.write(c)
    		#time.sleep(100 / 1000)
    		x = ser.read();
    
    
    price = 0;
    while 1:
    	try:
    		price = float(coinmarketcap.ticker('bitcoin')[0]['price_usd'])
    	except:
    		pass
    	lcd('BTC: ' + '${:,.2f}'.format(price))
    	time.sleep(60)
    

    /*
      Hello Serial LCD.c
    */
    
    #include "simpletools.h"
    
    serial *lcd;
    
    const int ON  = 22;
    const int CLR = 12;
    const int PIN = 0;
    const int LEN = 64;
    
    int main()
    {
      lcd = serial_open(PIN, PIN, 0, 19200);
      writeChar(lcd, 17);
      writeChar(lcd, ON);
      writeChar(lcd, CLR);
      putChar('n');
      char buffer[LEN+1];
      while(1){
        for(int i = 0;i < LEN;i++){
          char c = getChar();
          buffer[i] = c;
          putChar('n');
          if(c == '\0'){
            break; 
          }
        }
        dprint(lcd, "%s",buffer);
      }
      
        //writeChar(lcd,c);
        //putChar('n');
      
      //dprint(lcd, "Hello LCD!!!");
    }
    
  • brandan wrote: »
    I have an lcd on pin 0. I want to control an lcd screen with my code on my laptop. My current code is kinda slow, its only like 60 bytes per second. It uses an ack byte. I tried it without an ack byte, but the message gets corrupted or doesn't send.

    Here's my current code:


    const int PIN = 0;
    ...
    
    int main()
    {
      lcd = serial_open(PIN, PIN, 0, 19200);
    ....
    

    I don't know the definition of serial_open(), but would assume the first to parameters are the pins used for rx and tx. If you use the same pin for both you are talking to yourself.
    --
    Reinhardt
  • rbehm wrote: »
    I don't know the definition of serial_open(), but would assume the first to parameters are the pins used for rx and tx. If you use the same pin for both you are talking to yourself.

    That's how the propellor c tutorials do it.
Sign In or Register to comment.