I am trying to use joan's pigpio to write a serial command on my Rpi 3 gpio 14(UART0TX).My goal is to write a command from the pi to another device.

When i send the command i do not see the expected 11111111 on my oscope, nor do i see it on pigpio piscope. After reading some other post about serial issue i also used joan's GPIO MONITOR.

I am wondering if i am just not completely understanding the wave functions or if there is something else wrong?

Here is the relevant parts of my controller script, the send_command() function is what adds my command to the wave and sends it.

import sys
import difflib
import pigpio
import time
import os
from os import system

system('sudo pigpiod')

# rx GPIO pin constants
RX =  15       # 15
BAUD = 9600    # 9600
TX = 17        # NOT builtin gpio 14

#create instance of pigpio class
pi = pigpio.pi()
if not pi.connected:
    os.system("sudo pigpiod")
    pi = pigpio.pi()

pi.set_mode(TX, pigpio.OUTPUT) # set GPIO 14 as an output

def send_command(packet):
        pi.wave_add_serial(TX, BAUD, packet, bb_bits=8) #bb_bits=16
        wid = pi.wave_create()
        pi.wave_send_once(wid)   # transmit serial data
        while pi.wave_tx_busy(): # wait until all data sent
        print('The packet\n{}\n was sent!'.format(packet))
packet = b'11111111'
#packet = b'1'
#packet = '11111111'

here is the output of the wave_get functions:

control blocks: 98 max cbs: 25016 microseconds: 8440 max micros: 1800000000 pulses: 49 max pulses: 12000

if the packet i send is just packet = b'1' instead of packet = b'11111111' the output of the wave_get function is: control blocks: 14 max cbs: 25016 microseconds: 1146 max micros: 1800000000 **pulses: 7** max pulses: 12000 `

I thought sending a simple '1' would on be 1 pulse? the same idea above sending '11111111' i though that would be 8 pulses not 49?

  • Are you trying to use software serial or inbuilt UART? – Milliways Nov 20 '18 at 21:09
  • Have you a small but complete script? If so I can download and run it to see if there is a problem. – joan Nov 20 '18 at 21:09
  • @Milliways I am trying to use software serial. – Zack Jackson Nov 21 '18 at 13:34
  • @joan as for a complete script it would just be the the send_command() function I am using a GUI i built to pass "11111111" as the packet argument so i suppose if you just remove packet from the args and pass '11111111' to wave_add_serial() instead of packet that should do the trick. Milliways mentioned its inadvisable to use the default UART pins, ive noticed in your example scripts you dont use gpio14 either so is that true that I should use a different GPIO? – Zack Jackson Nov 21 '18 at 13:39
  • @joan i added a simple runnable script as per your request. In this version i tried using gpio17 rather than gpio14 as per Milliways suggestion. Using piscope I still am not reading the desired '11111111' data packet. I see the start bit low, the I would expect it to be high for 832usec followed by a stop bit but instead my data packet is a mix of low and high and is longer than i expected. – Zack Jackson Nov 21 '18 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.