Raspberry BASIC

Recent Posts

Pages: 1 ... 7 8 [9] 10
81
ScriptBasic / Pico
« Last post by John Spikowski on January 27, 2021, 08:53:40 PM »
I'm in the process of creating a ScriptBasic build for the new RPi Pico. ScriptBasic by design is an embeddable highly configurable micro controller scripting engine. It is used commercially by Banner Engineering and Controlled Soutions with their micro controller solutions.

If you have interest in joining me in this adventure, send support@raspberrybasic.org a request to join the forum.
82
General Discussion / Re: LG Library
« Last post by John Spikowski on January 24, 2021, 02:22:06 AM »
It seems that the author of the LG library also wrote pigpio

pigpio repository

pigpio home page

Both libraries seem to be public domain. I need to investigate the difference between them.
83
General Discussion / Re: LG Library
« Last post by John Spikowski on January 18, 2021, 06:16:42 PM »
I tried the DS18B20 on my RPi 3B under Raspbian and was able to get a valid result, It looks like the OWFS library doesn't work.


pi@RPi3B:~ $ cat /sys/bus/w1/devices/28-041780c226ff/w1_slave
3f 01 4b 46 7f ff 0c 10 f3 : crc=f3 YES
3f 01 4b 46 7f ff 0c 10 f3 t=19937
pi@RPi3B:~ $



From what my research has dug up so far is to get one-wire to work from the kernel a re-link needs to be done. One would think Ubuntu's RPi branch would have already addressed this issue of made it easy like Raspian to enable.

84
General Discussion / Re: LG Library
« Last post by John Spikowski on January 18, 2021, 03:56:20 AM »
I was able to get access to the DS18B20 using the OWFS interface. Problem is the returned temperature is all over the place. Not sure if this is progress or not.  :(

Reading a 1-wire DS18B20 temperature sensor using OWFS
85
General Discussion / Re: LG Library
« Last post by John Spikowski on January 18, 2021, 01:47:11 AM »
I can't seem to get the i2c 1-wire interface going on Ubuntu 64. I was able to get /sys/bus/w1/devices to show up after the modprobe commands but the devices folder is empty. Any advice how to get my DS18B20 to show up?

86
General Discussion / Re: LG Library
« Last post by John Spikowski on January 17, 2021, 03:55:42 AM »
I created a repository for the lg library on basic-sandbox.us. The only source I know of is from the author's site as a ZIP.

https://basic-sandbox.us/lg/lg-dev

I created a subdomain of RaspberryBASIC.org to host the lg library. The HTML for the site was created by a Python script that comes in the zip distribution.

https://lg.raspberrybasic.org

I feel much better that this public domain open source project won't disappear after spending time building a ScriptBasic extension module around it.
 





87
General Discussion / Re: LG Library
« Last post by John Spikowski on January 17, 2021, 03:11:29 AM »
The tx_pulse.c example.

Code: C
  1. /*
  2. tx_pulse.c
  3. 2020-11-18
  4. Public Domain
  5.  
  6. http://abyz.me.uk/lg/lgpio.html
  7.  
  8. gcc -Wall -o tx_pulse tx_pulse.c -llgpio
  9.  
  10. ./tx_pulse
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15.  
  16. #include <lgpio.h>
  17.  
  18. #define OUT 21
  19. #define LOOPS 120
  20.  
  21. #define LFLAGS 0
  22.  
  23. int main(int argc, char *argv[])
  24. {
  25.    int h;
  26.    int i;
  27.    double start, end;
  28.  
  29.    h = lgGpiochipOpen(0);
  30.  
  31.    if (h >= 0)
  32.    {
  33.       if (lgGpioClaimOutput(h, LFLAGS, OUT, 0) == LG_OKAY)
  34.       {
  35.          lgTxPulse(h, OUT, 20000, 30000, 0, 0);
  36.  
  37.          lguSleep(2);
  38.  
  39.          lgTxPulse(h, OUT, 20000, 5000, 0, LOOPS);
  40.  
  41.          start = lguTime();
  42.  
  43.          while (lgTxBusy(h, OUT, LG_TX_PWM)) lguSleep(0.01);
  44.  
  45.          end = lguTime();
  46.  
  47.          printf("%d cycles at 40 Hz took %.1f seconds\n", LOOPS, end-start);
  48.       }
  49.  
  50.       lgGpiochipClose(h);
  51.    }
  52. }
  53.  


jrs@RPi4B:~/lg/EXAMPLES/lgpio$ sudo ./tx_pulse
120 cycles at 40 Hz took 3.0 seconds
jrs@RPi4B:~/lg/EXAMPLES/lgpio$

88
General Discussion / Re: LG Library
« Last post by John Spikowski on January 17, 2021, 03:00:49 AM »
A toggle benchmark.

Code: C
  1. /*
  2. bench.c
  3. 2020-11-18
  4. Public Domain
  5.  
  6. http://abyz.me.uk/lg/lgpio.html
  7.  
  8. gcc -Wall -o bench bench.c -llgpio
  9.  
  10. ./bench
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15.  
  16. #include <lgpio.h>
  17.  
  18. #define LFLAGS 0
  19.  
  20. #define OUT 21
  21. #define LOOPS 20000
  22.  
  23. int main(int argc, char *argv[])
  24. {
  25.    int h;
  26.    int i;
  27.    double t0, t1;
  28.  
  29.    h = lgGpiochipOpen(0);
  30.  
  31.    if (h >= 0)
  32.    {
  33.       if (lgGpioClaimOutput(h, LFLAGS, OUT, 0) == LG_OKAY)
  34.       {
  35.  
  36.          t0 = lguTime();
  37.  
  38.          for (i=0; i<LOOPS; i++)
  39.          {
  40.             lgGpioWrite(h, OUT, 0);
  41.             lgGpioWrite(h, OUT, 1);
  42.          }
  43.  
  44.          t1 = lguTime();
  45.  
  46.          printf("%.0f toggles per second\n", (1.0 * LOOPS)/(t1-t0));
  47.       }
  48.  
  49.       lgGpiochipClose(h);
  50.    }
  51. }
  52.  


jrs@RPi4B:~/lg/EXAMPLES/lgpio$ sudo ./bench
139130 toggles per second
jrs@RPi4B:~/lg/EXAMPLES/lgpio$

89
General Discussion / Re: LG Library
« Last post by John Spikowski on January 17, 2021, 02:57:26 AM »
Here is the chipline.c program.

Code: C
  1. /*
  2. chipline.c
  3. 2020-11-18
  4. Public Domain
  5.  
  6. http://abyz.me.uk/lg/lgpio.html
  7.  
  8. gcc -Wall -o chipline chipline.c -llgpio
  9.  
  10. ./chipline
  11. */
  12. #include <stdio.h>
  13.  
  14. #include <lgpio.h>
  15.  
  16. int main(int argc, char *argv[])
  17. {
  18.    int h;
  19.    int i;
  20.    lgChipInfo_t cinf;
  21.    lgLineInfo_t linf;
  22.  
  23.    h = lgGpiochipOpen(0);
  24.    if (h >= 0)
  25.    {
  26.       if (lgGpioGetChipInfo(h, &cinf) == LG_OKAY)
  27.       {
  28.          printf("%d \"%s\" \"%s\"\n", cinf.lines, cinf.name, cinf.label);
  29.  
  30.          for (i=0; i<cinf.lines; i++)
  31.          {
  32.             if (lgGpioGetLineInfo(h, i, &linf) == LG_OKAY)
  33.             {
  34.                printf("%d %d \"%s\" \"%s\"\n",
  35.                   linf.offset, linf.lFlags, linf.name, linf.user);
  36.             }
  37.          }
  38.       }
  39.  
  40.       lgGpiochipClose(h);
  41.    }
  42. }
  43.  


jrs@RPi4B:~/lg/EXAMPLES/lgpio$ sudo ./chipline
58 "gpiochip0" "pinctrl-bcm2711"
0 0 "ID_SDA" ""
1 0 "ID_SCL" ""
2 0 "SDA1" ""
3 0 "SCL1" ""
4 0 "GPIO_GCLK" ""
5 0 "GPIO5" ""
6 0 "GPIO6" ""
7 7 "SPI_CE1_N" "spi0 CS1"
8 7 "SPI_CE0_N" "spi0 CS0"
9 0 "SPI_MISO" ""
10 0 "SPI_MOSI" ""
11 0 "SPI_SCLK" ""
12 0 "GPIO12" ""
13 0 "GPIO13" ""
14 0 "TXD1" ""
15 0 "RXD1" ""
16 0 "GPIO16" ""
17 0 "GPIO17" ""
18 0 "GPIO18" ""
19 0 "GPIO19" ""
20 0 "GPIO20" ""
21 0 "GPIO21" ""
22 0 "GPIO22" ""
23 0 "GPIO23" ""
24 0 "GPIO24" ""
25 0 "GPIO25" ""
26 0 "GPIO26" ""
27 0 "GPIO27" ""
28 0 "RGMII_MDIO" ""
29 0 "RGMIO_MDC" ""
30 0 "CTS0" ""
31 0 "RTS0" ""
32 0 "TXD0" ""
33 0 "RXD0" ""
34 0 "SD1_CLK" ""
35 0 "SD1_CMD" ""
36 0 "SD1_DATA0" ""
37 0 "SD1_DATA1" ""
38 0 "SD1_DATA2" ""
39 0 "SD1_DATA3" ""
40 0 "PWM0_MISO" ""
41 0 "PWM1_MOSI" ""
42 3 "STATUS_LED_G_CLK" "led0"
43 0 "SPIFLASH_CE_N" ""
44 0 "SDA0" ""
45 0 "SCL0" ""
46 0 "RGMII_RXCLK" ""
47 0 "RGMII_RXCTL" ""
48 0 "RGMII_RXD0" ""
49 0 "RGMII_RXD1" ""
50 0 "RGMII_RXD2" ""
51 0 "RGMII_RXD3" ""
52 0 "RGMII_TXCLK" ""
53 0 "RGMII_TXCTL" ""
54 0 "RGMII_TXD0" ""
55 0 "RGMII_TXD1" ""
56 0 "RGMII_TXD2" ""
57 0 "RGMII_TXD3" ""
jrs@RPi4B:~/lg/EXAMPLES/lgpio$
90
General Discussion / Re: LG Library
« Last post by John Spikowski on January 17, 2021, 02:42:10 AM »
I installed Ubuntu 20.10 64 bit using the Raspberry Pi Imaging Tool.

Attached is a screenshot.
Pages: 1 ... 7 8 [9] 10