libpruio (BB D/A - I/O fast and easy)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

Code: Select all

debian@beaglebone:~$ X=/sys/devices/platform/libpruio/state ; echo "ff06" > $X ; cat $X
tbclk=0/7 (orig/curr)
Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

Dinosaur wrote:

Code: Select all

debian@beaglebone:~$ X=/sys/devices/platform/libpruio/state ; echo "ff06" > $X ; cat $X
tbclk=0/7 (orig/curr)
Your libpruio-lkm package is not version 0.6.4c. Update it and the Pwm->Sync() function will work.
Dinosaur wrote:My software has an extensive "ErrControl" module that I usually apply to the finished product for the users benifit.
In libpruio such a module is build in, and you're the user.

Most of the code you sent still ignores the error messages, often it doesn't stop but just continues. When you line up a bunch of errors, you'll loose control over your development process.

Regards
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

According to this , it is.
Debian@beaglebone:~$ dpkg -l libpruio*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=========================-=================-=================-=======================================================
ii libpruio 0.6.4c armhf PRUSS driver for BB A/D-IO
ii libpruio-bas 0.6.4c armhf PRUSS driver for BB A/D-IO
ii libpruio-dev 0.6.4c armhf PRUSS driver for BB A/D-IO
ii libpruio-doc 0.6.4c all HTML-documentation for libpruio-dev packages
ii libpruio-lkm 0.6.4c armhf DKMS source for libpruio driver
ii libpruio-modules-4.14.94- 1stretch armhf libpruio modules
debian@beaglebone:~$
Regards

EDIT: Erasing MMCBlk1 did not help either.
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

I don't know what's wrong. You may check dmesg | grep libpruio for error codes.

Anyway, the kernel module at your system does not work as the 0.6.4c version. Perhaps an error message during installation of the package? Perhaps purging and re-installing will help (sudo apt purge libpruio-lkm ; sudo apt install libpruio-lkm)?

Regards
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

After purging and re-installing I got Linux Header files missing.
So, correcting that at the moment, but tell me what you were looking for in the statement:
debian@beaglebone:~$ X=/sys/devices/platform/libpruio/state ; echo "ff06" > $X ; cat $X
tbclk=0/7 (orig/curr)
so that I will know when I have the right response.

Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

Hi Dinosaur!
Dinosaur wrote:After purging and re-installing I got Linux Header files missing.
sudo apt install linux-headers
Dinosaur wrote:... so that I will know when I have the right response.
tbclk=0/6 (orig/curr)

Regarding your code

Code: Select all

#INCLUDE ONCE "BBB/pruio.bi"
#INCLUDE ONCE "BBB/pruio_pins.bi"
'==================================================================
'This test sets O/P P8-07 for single shot of Dur1
'First set P8_07 to Gpio Output to secure normal state.(Hi or Lo)
'If setting is Lo, set Mode = 2 ,Dur1 (Lo period) won't be visible.
'If setting is Hi, set Mode = 3 ,Dur1 (Hi period) won't be visible.
'NOTE: First time it is run after state change 2 pulses can occur.
'Dur1 = Space Time in mSec ie: 1.0
'Dur2 = Pulse Time in mSec ie: 3.0 is 3 mSec.
...
As I already said: it doesn't make sense to mux P8_07 to the GPIO subsystem first, and later mux it to the TIMER subsystem. This muxing process is not documented in the TRM. I don't know what happens nor what should happen. And the muxing process has an unpredictable latency.

Instead you should use the TIMER features to bring the pin in the desired state by replacing .Gpio->config(P8_07, PRUIO_GPIO_OUT0) by .Tim->config(P8_07, -1., -1., Mode), where Mode is either 1 for high, or 0 (zero) for low.

So you'll end up with

Code: Select all

#INCLUDE ONCE "BBB/pruio.bi"
#INCLUDE ONCE "BBB/pruio_pins.bi"
#DEFINE EEND(_T_)  ?"failed " & _T_ & " (" & *.Errr & ")" : GOTO Err_End
Dim Shared As Single Dur1 , Dur2
Dim Shared as SHORT Mode
VAR io = NEW PruIo()
    WITH *io
        IF .Errr THEN Goto Err_End
        IF .Tim->SetValue(P8_07, -1., -1., 0) THEN EEND("setting P8.07")
        IF .config() THEN EEND("config")
        Dur1 = 1
        Dur2 = 1
        Mode = 2
        If .Tim->SetValue(P8_07, Dur1, Dur2, Mode) Then EEND("changing P8.07")
        Print "Dur1= ";Dur1, "Dur2= ";Dur2
    END WITH
    Sleep
    Delete io
    End
Err_End:
    Print "Error End"
    Delete io
    End
Can you please test this code with your CRO, and report?

Regards
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

Running your code as is still starts a short fast pulse at the beginning of the space time.
However the setting of the output to Lo does work, other then when I quit the program
it returns to Hi, which setting by Gpio does not do.
If that is part of your code, then staying at the set level is desirable, but not that important.

Either way I will use that method as standard.

FINALLY some good news on pulse counting.
1: Debian or my version of the Kernel (4.14.94-ti-r95) has some oddities that are not consistent with Ubuntu.
Simply install linux-headers does not work, it takes (install linux-headers-$(uname -r) to accept.
That alone took me hours last night to find out.
2: Purging and re installing a number of times did not work either. I purged everything to do with libpruio,
but still no luck.

The only "errors" were:
At purge it could not find libpruio.ko to delete it by looking in /lib/modules/4.14.94-ti-r95
Then at re-install it said that libpruio.ko was later then the Kernel, and I could "--force" it.
Even with --reinstall the same error and it did not replace it.
So eventually I found it in /lib/modules/4.14.94-ti-r95/extras and manually deleted it.

After the next reinstall the Sync(&b000) and Sync(&b110) worked perfectly.
Will send you a pdf.

We ARE making progress.

Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

Dinosaur wrote:After the next reinstall the Sync(&b000) and Sync(&b110) worked perfectly.
Good news, congrats!
Dinosaur wrote:it returns to Hi, which setting by Gpio does not do.
If that is part of your code, then staying at the set level is desirable, but not that important.
I'll care about that later. First I'll need further testing with the current binary:
Dinosaur wrote:Running your code as is still starts a short fast pulse at the beginning of the space time
OK, this happens when starting in regular mode (first low, then high). What happens in 'invers' mode (first high, then low). Do you also see a (low) pulse at the beginning of Dur1?

Regards
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF
What happens in 'invers' mode (first high, then low).
I meant to tell you that before. I have tested that and the same thing happens.
It is worth noting that it happens about 30% of the time, and by watching the voltage of that early pulse
you can see that it changes. Sometimes it makes it to the full 3.3 v, other times it only reaches 1/2 that.
On rare occasions it only gets to about 0.3 v.
So it looks like a "time race" thing.

Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

Dinosaur wrote:
What happens in 'invers' mode (first high, then low).
I meant to tell you that before.
All your former information is about code including pinmuxing [Pwm to Tim]. I need information about the output without pinmuxing, while changing from stopped to running TIMER [Tim->setValue(P8_07, -1., -1, Mode) to Tim->setValue(P8_07, Dur1, Dur2, Mode)].
Dinosaur wrote:I have tested that and the same thing happens.
It is worth noting that it happens about 30% of the time, and by watching the voltage of that early pulse
you can see that it changes. Sometimes it makes it to the full 3.3 v, other times it only reaches 1/2 that.
On rare occasions it only gets to about 0.3 v.
So it looks like a "time race" thing.
This looks like a high impedance pin (no way to avoid that). What happens when you ground the pin by a 10-100 kOhm resistor for regular mode, or pull-up the pin in invers mode? (You could use the internal resistors for that.)

Regards
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

Actually I have been tackling 2 problems at the same time.
1 is the extra pulse
2 is the Sync not working.

Either way the code below is what I have been using to test for the extra pulse.

Code: Select all

#INCLUDE ONCE "BBB/pruio.bi"
#INCLUDE ONCE "BBB/pruio_pins.bi"
'==================================================================
'This test sets O/P P8-07 for single shot of Dur2
'First set P8_07 to secure normal state.(Hi or Lo)
'If setting is Lo, set Mode = 2 ,Dur1 (Lo period) won't be visible.
'If setting is Hi, set Mode = 3 ,Dur1 (Hi period) won't be visible.
'Dur1 = Space Time in mSec ie: 1.0
'Dur2 = Pulse Time in mSec ie: 3.0 is 3 mSec.
'
'CONCLUSION: Total of (Dur1 + Dur2) must be 0.005001 mSec or more.
'            If both are 0.005 the SetValue will Err.
'            Maximum Freq is then 100 Khz.
'==================================================================
Dim Shared As Double Dur1 , Dur2
Dim Shared as SHORT Mode

VAR io = NEW PruIo()
    WITH *io
        IF .Errr THEN Goto Err_End
        IF .Tim->SetValue(P8_07, -1., -1., 1) THEN Goto Err_END
        IF .config() THEN Goto Err_End
        Dur1 = 1
        Dur2 = 1
        Mode = 3
        If .Tim->SetValue(P8_07, Dur1, Dur2, Mode) Then
            Print "Errer 2"
            Goto Err_End
        EndIf
        Print "Dur1= ";Dur1, "Dur2= ";Dur2
        Do
            VAR k  = Asc(INKEY())
            Select Case AS CONST k
                Case Asc("1")           'do it again'
                    .Tim->SetValue(P8_07, Dur1, Dur2, Mode)
                Case Asc("q")           'quit'
                   Exit Do
            End Select
        Loop
    END WITH
    Delete io
    End
Err_End:
    Print "Error End"
    Delete io
    End
Will see what I can do with pin impedance.

EDIT: Putting a 1k resistor from P8_07 to an led then to the +5v rail does not change the extra pulse.

Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

Dinosaur wrote:EDIT: Putting a 1k resistor from P8_07 to an led then to the +5v rail does not change the extra pulse.
That's not what I mean. The following code starts the timer in different configurations. You can add the internal pull-up (key 'u') or pull-down (key 'd') resistor to the output. Please measure one-shots: normal and invers mode, both with either pull-down or pull up resistor.

Code: Select all

#INCLUDE ONCE "BBB/pruio.bi" '   include header
#INCLUDE ONCE "BBB/pruio_pins.bi" '   include header

#DEFINE EMSG(_T_) ?_T_ & " failed (" & *.Errr & ")" : EXIT DO
#DEFINE P_OUT0 P8_07
#DEFINE P_OUT1 P9_42
VAR io = NEW PruIo()              '*< create new driver UDT

WITH *io
DO
  IF .Errr THEN                                             EMSG("CTOR")
  VAR d1 = -1. _
    , d2 = -1. _
    , o1 = 0. _
    , o2 = 0. _
    , mo = &b00 _
    , mu = CUBYTE(PRUIO_NO_PULL) _
    , k = "" _
    , po = P_OUT1 _
    , pn = P_OUT0
  IF .Tim->setValue(pn, d1, d2, mo) THEN            EMSG("pinmux P_TIM")
  IF io->config() THEN                                    EMSG("config")
  DO
    ?" Dur1 = " & d1 & ", Dur2 = " & d2 & ", Mo = " & BIN(mo, 2) _
                     & ", Pin = " & *IIF(pn = P8_07, @"P8_07", @"P9_42") _
                     & ", Pull = " & *IIF(mu = PRUIO_PULL_UP, @"UP", _
                                      IIF(mu = PRUIO_PULL_DOWN, @"DOWN", @"NONE"))
    DO : k = INKEY() : IF LEN(k) THEN EXIT DO
      SLEEP 1
    LOOP

    SELECT CASE k
    CASE "i" : ?"i:"; : mo XOR= &b001 ' toggle invers
    CASE "o" : ?"o:"; : mo XOR= &b010 ' toggle one shot
    CASE "s" : ?"s:"; : SWAP d1, o1 : SWAP d2, o2
    CASE "y" : ?"y:"; : SWAP po, pn ' swap output pin PWM/TIM
    CASE "d" : ?"d:"; : mu = PRUIO_PULL_DOWN ' pull-down
      .setPin(io, pn, (.BallConf[pn] AND &b11100111) OR mu)
    CASE "n" : ?"n:"; : mu = PRUIO_NO_PULL ' no resistor
      .setPin(io, pn, (.BallConf[pn] AND &b11100111) OR mu)
    CASE "u" : ?"u:"; : mu = PRUIO_PULL_UP ' pull-up
      .setPin(io, pn, (.BallConf[pn] AND &b11100111) OR mu)
    CASE "=" : ?"=:"; : d1 =  0 : d2 = 10
    CASE "0" : ?"0:"; : d1 = 10 : d2 =  0
    CASE "1" : ?"1:"; : d1 =  9 : d2 =  1
    CASE "2" : ?"2:"; : d1 =  8 : d2 =  2
    CASE "3" : ?"3:"; : d1 =  7 : d2 =  3
    CASE "4" : ?"4:"; : d1 =  6 : d2 =  4
    CASE "5" : ?"5:"; : d1 =  5 : d2 =  5
    CASE "6" : ?"6:"; : d1 =  4 : d2 =  6
    CASE "7" : ?"7:"; : d1 =  3 : d2 =  7
    CASE "8" : ?"8:"; : d1 =  2 : d2 =  8
    CASE "9" : ?"9:"; : d1 =  1 : d2 =  9
    CASE ELSE : EXIT DO
    END SELECT

    IF .Tim->setValue(pn, d1, d2, mo) THEN        EMSG("changing P_TIM")
  LOOP UNTIL LEN(INKEY()) : ?

LOOP UNTIL 1
END WITH

DELETE io                         '   destroy driver UDT

Regards
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

Will do over the next few hours, so will send tomorrow (my time)
but will email pdf's to you so you can see.

Are you receiving the pdf's I have sent ?

Regards
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: libpruio (BB D/A - I/O fast and easy)

Post by TJF »

Dinosaur wrote:Are you receiving the pdf's I have sent ?
No. I didn't receive any PM. Did you email to the address published in the docs license?
Dinosaur
Posts: 1478
Joined: Jul 24, 2005 1:13
Location: Hervey Bay (.au)

Re: libpruio (BB D/A - I/O fast and easy)

Post by Dinosaur »

Hi TJF

Yes I did, and about to send you an analyses of the test.
Do you still want me to send it to the same ?

Regards
Post Reply