Shop OBEX P1 Docs P2 Docs Learn Events
Propbasic and SEROUT... — Parallax Forums

Propbasic and SEROUT...

dennodenno Posts: 219
edited 2018-08-14 13:26 in Propeller 1
First of all, I am not sure on how to post code, other then copy and paste here...so forgive me on that one....The .pbas below, does compile and the LED's do blink as indicated, however, I cannot get the SEROUT to work to a Scott Edwards 4X20 display. I have used many of these displays over the years with the Basic Stamp, with excellent results...Does anyone have any ideas on this...?
DEVICE P8X32A, XTAL1, PLL16X
XIN 5_000_000

baud                   CON "T9600"
carr_return            CON  13   
clrLCD                 CON  12          'clear the screen on the lcd
posCMD                 CON  16          'position the curser command
hideCUR                CON   4           'hide the curser command
blinkCUR               CON   6           'blink the curser command
degreeSYM              CON 223           'the "degree" symbol
receive_data           CON 255
backLTon               CON  14          'turn the back light on
backLToff              CON  15          'turn the back light off
brightness_ctl         CON  27
quarter_bright         CON  48
half_bright            CON  49
three_quarter_bright   CON  50
full_bright            CON  51
beep                   CON   7           'beep command
right_align            CON  18          'RIGHT ALIGN COMMAND
start_big_char         CON   2
end_big_char           CON   3
astrike                CON  42
block_char             CON 134
carReturn              CON  13          'carriage return command
blank_char             CON  32
left_arrow             CON 127
right_arrow            CON 126
LR_arrow               CON 131
LL_arrow               CON 128
UR_arrow               CON 129
UL_arrow               CON 130
down_arrow             CON 132
up_arrow               CON 133
equal_sign             CON  61
first_line             CON  64
second_line            CON 104          

message DATA “Hello There.”

flash_16_LED  task
flash_17_LED  task
flash_18_LED  task
LCD                task
pause 100
PROGRAM Start
Start:
 COGINIT Flash_16_LED, 2 ' Start task in COG 2
 COGINIT Flash_17_LED, 3
 COGINIT Flash_18_LED, 4
 COGINIT LCD,5
END
''''''''
TASK LCD
LCD_data_out           PIN 0 OUTPUT
   SEROUT LCD_data_out, baud, beep
   SEROUT LCD_data_out, baud, message
ENDTASK
'''''''
TASK flash_16_LED
  LED_16 PIN 16 LOW 
 DO
   TOGGLE LED_16
   PAUSE 200
 LOOP
ENDTASK
'''''''
TASK Flash_17_LED
  LED_17 PIN 17 LOW
 DO
   TOGGLE LED_17
   PAUSE 400
 LOOP
ENDTASK
''''''
TASK Flash_18_LED
  LED_18 PIN 18 LOW
 DO
   TOGGLE LED_18
   PAUSE 1000
 LOOP
ENDTASK

Comments

  • VonSzarvasVonSzarvas Posts: 3,272
    edited 2018-08-14 13:26
    denno wrote: »
    First of all, I am not sure on how to post code, other then copy and paste here...

    Check out the 3 attached images. Do they help explain ?

    Parallax_Forum_Code_Step1.png
    Parallax_Forum_Code_Step2.png
    Parallax_Forum_Code_Step3.png


    Click the "C" button to get code tags, then type your code (or copy/paste code) between those tags.



    1435 x 544 - 36K
    1435 x 544 - 37K
    1435 x 500 - 51K
  • PublisonPublison Posts: 12,366
    edited 2018-08-14 13:27
    Use the "C" in the top bar when posting. Copy your code and paste between the
    
    .
    EDIT @VonSzarvas beat me to it.
  • About the serout question...

    Check the PropBasic user guide explanation of the SEROUT baud parameter, and make sure that's correct for compatibility with the Scott Edwards module.
    baud                   CON "T9600"
    

    There are a couple different operation modes (T and O as I recall), different baud rates, and also different ways to make the connections between the devices (like with a pull-up or pull-down resistor, or without any pull resistor).

    Perhaps you have the baud rate correct as you've been using the modules before, but the other settings are less obvious and might differ from how it worked with Basic Stamp. So this might be a place to start investigating.


  • BeanBean Posts: 8,129
    For true "T" serout mode, the line should be HIGH when it is idle.
    So in the TASK make the line HIGH then wait a couple milliseconds before sending commands.

    PropBASIC super fast compared to a Basic Stamp. You may have to put some delays in after the BEEP.

    Bean
  • Thanks again for showing/telling me how to copy code to the forums...I have tried all possible combos with the BAUD rate, pulling the LCD_data_out line on P0 HIGH..etc. Still no joy. Even installed PAUSES as Bean suggested...
    DEVICE P8X32A, XTAL1, PLL16X
    XIN 5_000_000
    
    baud                   CON "T9600"
    carr_return            CON  13   
    clrLCD                 CON  12          'clear the screen on the lcd
    posCMD                 CON  16          'position the curser command
    hideCUR                CON   4           'hide the curser command
    blinkCUR               CON   6           'blink the curser command
    degreeSYM              CON 223           'the "degree" symbol
    receive_data           CON 255
    backLTon               CON  14          'turn the back light on
    backLToff              CON  15          'turn the back light off
    brightness_ctl         CON  27
    quarter_bright         CON  48
    half_bright            CON  49
    three_quarter_bright   CON  50
    full_bright            CON  51
    beep                   CON   7           'beep command
    right_align            CON  18          'RIGHT ALIGN COMMAND
    start_big_char         CON   2
    end_big_char           CON   3
    astrike                CON  42
    block_char             CON 134
    carReturn              CON  13          'carriage return command
    blank_char             CON  32
    left_arrow             CON 127
    right_arrow            CON 126
    LR_arrow               CON 131
    LL_arrow               CON 128
    UR_arrow               CON 129
    UL_arrow               CON 130
    down_arrow             CON 132
    up_arrow               CON 133
    equal_sign             CON  61
    first_line             CON  64
    second_line            CON 104          
    
    message DATA “Hello There.”
    
    flash_16_LED  task
    flash_17_LED  task
    flash_18_LED  task
    LCD           task
    pause 100
    PROGRAM Start
    Start:
     COGINIT Flash_16_LED, 2 ' Start task in COG 2
     COGINIT Flash_17_LED, 3
     COGINIT Flash_18_LED, 4
     COGINIT LCD,5
    END
    ''''''''
    TASK LCD
       LCD_data_out  PIN 0  HIGH
       PAUSE 1000
       SEROUT LCD_data_out, baud, beep
       PAUSE 1000
       SEROUT LCD_data_out, baud, posCMD
       SEROUT LCD_data_out, baud, 64
       SEROUT LCD_data_out, baud, message
    ENDTASK
    '''''''
    TASK flash_16_LED
      LED_16 PIN 16 LOW 
     DO
       TOGGLE LED_16
       PAUSE 200
     LOOP
    ENDTASK
    '''''''
    TASK Flash_17_LED
      LED_17 PIN 17 LOW
     DO
       TOGGLE LED_17
       PAUSE 400
     LOOP
    ENDTASK
    ''''''
    TASK Flash_18_LED
      LED_18 PIN 18 LOW
     DO
       TOGGLE LED_18
       PAUSE 1000
     LOOP
    ENDTASK
    
  • BeanBean Posts: 8,129
    Are you sure it will work with 3.3V signals ? The Basic Stamp uses 5.0V signals.

    Bean
  • dennodenno Posts: 219
    edited 2018-08-15 10:48
    Yes, Bean, I do believe you are correct, and that is the same thing that Scott Edwards said from Seetron, that makes the displays. Anyone got any ideas of a 3.3 volt to 5 volt data signal amplifier...? Optoisolator...? 3.3 volt on the input with a small current limit resistor, and 5 volts on the other side?
  • A "level shifter" is what you're looking for. Something like https://www.sparkfun.com/products/11771
    Mouser, Digikey, etc., have dozens if not hundreds of different kinds.
    Mike R...
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2018-08-15 13:30
    I also make and sell a high quality 20x4 serial LCD and I use a HCT86 gate on the input so that I can use inverted RS232 or logic levels, down to 2V. In fact these units were made to replace those expensive Seetron displays, especially for use in bright outdoor sunlight as well as backlit for night but my displays have electronic contrast and dimming built-in for that reason too. The backpack itself is a very low profile surface-mount module.
  • For what is worth...I was able, using SPIN to send data (SPI) to a Scott Edwards LCD, using the 3.3 volt out of the Propeller. So, I do know that 3.3 volts will work the LCD.

    However, I cannot get .PBAS to write to the same LCD. Which, makes me wonder if I have the latest version of .PBAS. The .PBAS manual is version, 1.48, but I think the IDE, I have is 1.43. How do I tell for sure, and has anyone used an LCD in .PBAS, and if so, do you have any example codes...?

    Thanks...DennO
Sign In or Register to comment.