[Feb 26] Recalbox beta v3.1- Rock64 |[Feb 26] Recalbox 190222- RockPro64 / Minimal Debian by mrfixit2001 - 190222 - RockPro64 |[Feb 26] Q4OS 2.7-r2 - Pinebook 1080P / Pinebook |[Feb 22] Batocera Linux 5.20-20190121- RockPro64 | [Feb 19] Manjaro KDE 19.02 / Manjaro LXQT 19.02 - Pinebook1080P / Pinebook | [Feb 19] Slackware Aarch64 Miniroot and XFCE 20190201 - RockPro | [Feb 19] Slackware Aarch64 Miniroot and XFCE 20190201 - Rock64

Project Inspiration | Get Started | IRC Logs | Forum Rules/Policy


Padi Stamp v2.2.1, v3.5 (2016/10/08-16:57:18)
#21
As you might guess, each Arduino with attached padi is able to create a client connection with the AT command ATPC.  When each client attaches to the pine board padi ( server  ATPS ) a separate con_id (and socket) is created for each client connect !   ( how cool is that ? )

The ATPI command can then be used on the server to "see" all the connections and then the 'protocol' ( up to you ) can do a 'push' or 'pull' from each client;  and this all over wifi... no messy one or two wire feeds all over the house, or lab, or yatch...   

... so each Arduino is handling the real-time data acquisition , and the pine server is doing all the data gathering and analytics !   Its a good thing these little boards ( padi ) are only $2 because I'm going to need a couple of dozen of them.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#22

.pdf   padi_pine_block_diagram_2.pdf (Size: 34.94 KB / Downloads: 93)

The above pdf is a functional block diagram of my padi test setup;  the padi stamp is attached to the pine board via serial cable ( modified cat5 twisted pairs ) such that the pine /dev/ttyS3 is connected directly to the serial console of the padi at GA0 and GA4. 

I have created two dummy loads ( LEDs ) which draw too much current for the padi gpio to drive directly;  each LED load has a 2N2222 driver transistor and each is powered from the 5v rail. 

To complete the following experiments ( and use the provided python codes ) it is important to use this command:

sudo  chmod  0777  /dev/ttyS3 

You can communicate with the padi directly ( manually ) with 'screen',  'minicom',  &  'cu'.  In this post I am using Python2 to communicate with the padi under program control ( use the script provided below ) and the python2 REPL. The padiserial.py script is a framework for controlling the padi via python2 which deliberately minimizes the robustness of software engineering, and provides a simple example module for controlling the padi ( including gpio ) from the /dev/ttyS3 uart serial interface to the padi serial console.

I will post the python2 module here, and then give some comments following:

padiserial.py

Code:

# padiserial.py  v0.1e
#
# mark h harris
# 11-5-2016
#
# core
#    ser.open()
#    ser.close()
#    ser.isOpen()
#    ser.read(n)
#    ser.write('ATx\r')
#    ser.inWaiting()
#
# extended
#    serfmt(n)        serfmt(ser.inWaiting())
#    serwrt('ATxx')
#    serend()
#
# gpio
#    GC1(isbool)
#    GC2(isbool)
#    GC1_blink(n, n_time)
#    GC2_blink(n, n_time)
#    red(n_blink)
#    yellow(n_blink)
#    on_red(isbool)
#    on_yellow(isbool)
#    blinker()

import serial as SER
import time as TM

ser = SER.Serial (
    port='/dev/ttyS3',
    baudrate=38400,
    parity=SER.PARITY_NONE,
    stopbits=SER.STOPBITS_ONE,
    bytesize=SER.EIGHTBITS
)

def serfmt(n):
    outp=''
    for i in range(n):
        inp=ser.read(1)
        if inp!='\r' and inp!='\n':
            outp+=inp
        if inp=='\r':
            a=1
        if inp=='\n':
            print(outp)
            outp=''

def serwrt(datastr):
    return ser.write(datastr + '\r')

def GC1(isbool):
    if isbool:
        onoff='1'
    else:
        onoff='0'
    wrtlen = serwrt('ATSG=W,PC_1,'+onoff+',1')

def GC2(isbool):
    if isbool:
        onoff='1'
    else:
        onoff='0'
    wrtlen = serwrt('ATSG=W,PC_2,'+onoff+',1')

def GC1_blink(n, n_time):
    for i in range(n):
        GC1(True)
        TM.sleep(n_time)
        outnull = ser.read(ser.inWaiting())
        GC1(False)
        TM.sleep(n_time)
        outnull = ser.read(ser.inWaiting())

def GC2_blink(n, n_time):
    for i in range(n):
        GC2(True)
        TM.sleep(n_time)
        outnull = ser.read(ser.inWaiting())
        GC2(False)
        TM.sleep(n_time)
        outnull = ser.read(ser.inWaiting())

def red(n_blink):
    GC1_blink(n_blink, .250)

def yellow(n_blink):
    GC2_blink(n_blink, .250)

def on_red(isbool):
    GC1(isbool)
    TM.sleep(.350)
    outnull = ser.read(ser.inWaiting())

def on_yellow(isbool):
    GC2(isbool)
    TM.sleep(.350)
    outnull = ser.read(ser.inWaiting())

def blinker():
    kybInt=False
    cycleCount=0
    startTime=TM.time()
    while not kybInt:
        try:
            red(1)
            yellow(1)
            cycleCount+=1
        except KeyboardInterrupt:
            mins_time=(TM.time()-startTime)/60.0
            cpm_freq=cycleCount/mins_time
            on_red(0)
            on_yellow(0)
            print('\n\nCycle Count: '+str(cycleCount)+'\n')
            print('\ntime: '+str(mins_time)+' mins.\n')
            print('\ntime: '+str(mins_time/60.0)+' hrs.\n')
            print('\nfreq: '+str(cpm_freq)+' cpm.\n')
            print('\nblinker successfully terminated via interrupt\n')
            TM.sleep(.225)
            kybInt=True

def serend():
    ser.close()
    quit()


Place the above codes in a script called  padiserial.py  then place the module in your working directory, and start the python2 REPL;   just type  python,  then import the module with:

>>>  from padiserial import *
>>>

You may now use the functions in the module ;  examples follow:

>>> serwrt('ATWS')        # wait a bit here for the wifi scan to complete
5
>>> serfmt(ser.inWaiting())

(output from the write will appear here)

>>> red(7)     #  this will blink the red LED load seven times

>>> on_yellow(True)     # this will turn the yellow load on

>>> on_red(False)      # this will turn the red load off

>>> serwrt('ATSR')     # this will reboot the padi

>>> serfmt(ser.inWaiting())    #  this will read and display any serial characters in the buffer from the padi

>>> ser.close()    #  will close the connection

>>> ser.open()   # will reopen the connection

>>> ser.isOpen()    #  will tell you if the open() worked

Obviously read the source in the padiserial.py script;  all the functions are documented there, as well the serial framework for python2 uart communication is also documented there.

The test setup block diagram faithfully represents the pics at the start of this blog.  As I continue to add the Arduino units additional block diagrams will appear ;  as well, the C|C++  sketch for the Arduino will be provided.

   
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#23
PS:  You can add the following blinker() code to the padiserial.py ( see previous posting ) script which will allow you to hammer on the padi's console and gpio during the burnin period;  great little test-- and fun.

Code:
def blinker():
    kybInt=False
    cycleCount=0
    startTime=TM.time()
    while not kybInt:
        try:
            red(1)
            yellow(1)
            cycleCount+=1
        except KeyboardInterrupt:
            mins_time=(TM.time()-startTime)/60.0
            cpm_freq=cycleCount/mins_time
            on_red(0)
            on_yellow(0)
            print('\n\nCycle Count: '+str(cycleCount)+'\n')
            print('\ntime: '+str(mins_time)+' mins.\n')
            print('\ntime: '+str(mins_time/60.0)+' hrs.\n')
            print('\nfreq: '+str(cpm_freq)+' cpm.\n')
            print('\nblinker successfully terminated via interrupt\n')
            TM.sleep(.225)
            kybInt=True

note:  also,  it allows testing of the 'green' activity LED on the padi stamp;  is enough activity to keep the green LED blinking steadily too.

note:  ctrl-C  gives the keyboardInterrupt for cancel
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#24
(11-05-2016, 01:43 PM)MarkHaysHarris777 Wrote: PS:  You can add the following blinker() code to the padiserial.py ( see previous posting ) script which will allow you to hammer on the padi's console and gpio during the burnin period;  great little test-- and fun.

Code:
def blinker():
    kybInt=False
    cycleCount=0
    startTime=TM.time()
    while not kybInt:
        try:
            red(1)
            yellow(1)
            cycleCount+=1
        except KeyboardInterrupt:
            mins_time=(TM.time()-startTime)/60.0
            cpm_freq=cycleCount/mins_time
            on_red(0)
            on_yellow(0)
            print('\n\nCycle Count: '+str(cycleCount)+'\n')
            print('\ntime: '+str(mins_time)+' mins.\n')
            print('\ntime: '+str(mins_time/60.0)+' hrs.\n')
            print('\nfreq: '+str(cpm_freq)+' cpm.\n')
            print('\nblinker successfully terminated via interrupt\n')
            TM.sleep(.225)
            kybInt=True

note:  also,  it allows testing of the 'green' activity LED on the padi stamp;  is enough activity to keep the green LED blinking steadily too.

note:  ctrl-C  gives the keyboardInterrupt for cancel

famous blinking code Smile
Reply
#25
I updated the codes with blinker().
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#26
Addendum:  baud rate 38400

You're not limited to baud rate on the console of 38400;  in fact,  all of the comm parameters may be changed with the ATSU command:

ATSU=<baudrate>,<databits>,<stopbits>,<parity>,<flowcontrol>,<configmode>

... and with the ATPL=1 you can save the new configuration to flash memory.

Unlike gpio controls on other boards, the gpio control of the padi ( out-of-box ) requires the use of the AT command set;  so some of the time in the gpio duty cycle is writing ( and reading ) the serial comms. My famous blinker codes in the posting(s) above should have a maximum cycles/min of 60 based on timing; however, the measured cycles/min are consistently over time about ~ 59.83 cpm ( the reason is the time is takes to transact the serial comms ).  The number will be closer to 60 with the baud rate set to 115200.



note:   using the configmode parameter you can set the new baud rate ( save it to flash ) and have it take effect after reboot ( ATSR )  with configmode '2'

note:   baud rate up to 1152000 is supported;  I am currently testing with standard 115200.


-
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#27
Have you spotted the red LED yet? The PADI has two leds hidden down that hole, green appears to be primarily for serial TX(from PADI), and red is for serial RX (to PADI). It doesn't look like the green one doubles for anything else like wifi activity as it never triggers when you ping the padi, or send it data without it set to auto-print.
Reply
#28
(11-11-2016, 07:14 PM)pfeerick Wrote: Have you spotted the red LED yet? The PADI has two leds hidden down that hole, green appears to be primarily for serial TX(from PADI), and red is for serial RX (to PADI). It doesn't look like the green one doubles for anything else like wifi activity as it never triggers when you ping the padi, or send it data without it set to auto-print.

haha  yes,  I have to admit that I noticed the little red LED too...  because I accidentally reversed polarity on my power pins and that sucker went red solid !!!    Blush

sooo,  don't do that !    Angel

I'll try a test with just repeated reads to see if I can see it come on for normal reasons...    Wink
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#29
(11-11-2016, 07:24 PM)MarkHaysHarris777 Wrote: haha  yes,  I have to admit that I noticed the little red LED too...  because I accidentally reversed polarity on my power pins and that sucker went red solid !!!    Blush

It's pretty hard to spot at times... most noticeable if you use a terminal config that sends each character as you type them... then you get to see it blink each time. Else you might see a red flash before a blinding green one! :-O  Tongue

Oh dear... but the real question we want to know now is did the magic smoke come out, or did the patient survive the traumatic experience?
Reply
#30
(11-12-2016, 12:00 AM)pfeerick Wrote:
(11-11-2016, 07:24 PM)MarkHaysHarris777 Wrote: haha  yes,  I have to admit that I noticed the little red LED too...  because I accidentally reversed polarity on my power pins and that sucker went red solid !!!    Blush

It's pretty hard to spot at times... most noticeable if you use a terminal config that sends each character as you type them... then you get to see it blink each time. Else you might see a red flash before a blinding green one! :-O  Tongue

Oh dear... but the real question we want to know now is did the magic smoke come out, or did the patient survive the traumatic experience?

no magic smoke;  tough little chip.  I don't recommend trying it--- but mine survived and continues to function well within parameters.   Shy

Note:   ok, I found the little red LED on my padi(s)  its difficult to see because its at the bottom of the view port ( in fact mine is slightly covered also ) so I have to look into the view port from the top to see it clearly, and then transmit one character at a time...  for instance even in line mode you can see this by entering a first character other than 'A' ( you'll get an error 'should start with A' and the red LED will light momentarily )


Note:   in fact,  if I look into the view port from the top at a sharp angle I can see the red LED blinking alternately with the green LED ;  although, not as brightly,   with the blinker() codes posted above.

~cool
Smile
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Basic question ti use padi ad i/o remote module [email protected] 2 787 11-02-2018, 02:20 PM
Last Post: [email protected]
  some questions regarding the PADI schepers_cp 10 1,187 08-20-2018, 09:49 AM
Last Post: dkryder
Information Padi IRC Channel pfeerick 1 1,075 07-17-2017, 02:47 PM
Last Post: tllim
  PADI IoT Dongle used for GPIO Expansion MarkHaysHarris777 14 4,093 04-05-2017, 03:21 PM
Last Post: MarkHaysHarris777
  Padi Stamp LED pcb symbol is incorrect dkryder 4 1,365 03-11-2017, 11:02 PM
Last Post: pfeerick
  Several PADI connected to Pine via Wifi Traveler 3 1,028 02-07-2017, 07:10 AM
Last Post: MarkHaysHarris777
  broadcasting with padi stamp ? Grag38 2 605 01-31-2017, 08:23 AM
Last Post: Grag38
  PADI IoT Stamp is starting to get noticed... pfeerick 12 2,412 12-15-2016, 10:42 AM
Last Post: tllim

Forum Jump:


Users browsing this thread: 1 Guest(s)