Author Topic: Control digital, pwm and analog signals from QB64  (Read 5702 times)

0 Members and 1 Guest are viewing this topic.

Offline mdijkens

  • Newbie
  • Posts: 34
    • View Profile
Control digital, pwm and analog signals from QB64
« on: March 16, 2022, 04:45:39 am »
Triggered by a question on the forum from Parkland here https://qb64forum.alephc.xyz/index.php?topic=4723.0, I wanted to see how high a performance (reads/writes per second) I could get by controlling a NodeMCU (ESP8266 12E) from QB64
Attached my program that can get up to 4800 datapoints/sec via USB. It is only limited by the max baudrate of qb64 (115k2).
It can read analog, digital, pwm and write digital, pwm.
add/remove what you need to get maximum performance
* mdESP8266.7z (Filesize: 3.13 KB, Downloads: 188)
« Last Edit: March 18, 2022, 06:12:20 am by mdijkens »
~ 2 million lines of BASIC

Offline david_uwi

  • Newbie
  • Posts: 71
    • View Profile
Re: Control digital, pwm and analog signals from QB64
« Reply #1 on: March 16, 2022, 11:10:23 am »
I use a FT201X connected to one of microchip's PIC chips (16F18326 usually) the chip has ADC and can read from other sensors using I2C and SPI.
The transfer rate I have observed seems to be governed by how fast the FT201X can access and transfer the data to the USB line.
In other words the baud rate you put in the OPEN COM line seems unimportant (it may well be for transfer the other way).
I get speeds of about 185 kbaud  (I can transfer 1 Mbyte in 45 secs) which is well over the supposed maximum of 115k.

Offline mdijkens

  • Newbie
  • Posts: 34
    • View Profile
Re: Control digital, pwm and analog signals from QB64
« Reply #2 on: March 16, 2022, 11:38:42 am »
Intereseting

The CH340G on some ESP boards is capable of 2Mbit USB Serial speeds, so worth to give it a try too.
Do you just enter a higher baudrate in the OPEN statement or just 115200 ?
~ 2 million lines of BASIC

Offline david_uwi

  • Newbie
  • Posts: 71
    • View Profile
Re: Control digital, pwm and analog signals from QB64
« Reply #3 on: March 16, 2022, 02:49:38 pm »
I found that when reading into QB64 the baud rate in the open statement did not matter. I have not tried the other way as I don't have much data to transfer.
My transfer rate I feel is limited by how fast the other parts of the circuit can access the data. I was transferring weather data from a flash memory chip (part of a data-logger) to my PC. I've just looked up the memory chip FL132K and it seems to be obsolete (these thing happen quickly!) it holds 4 Mbytes may seem small, but even recording temperature and pressure reading every minute it can last a few years (the batteries run down first).

Offline mdijkens

  • Newbie
  • Posts: 34
    • View Profile
Re: Control digital, pwm and analog signals from QB64
« Reply #4 on: March 18, 2022, 06:10:51 am »
Ik heb nog wat meer geexperimenteerd met de baudrate en daar valt inderdaad nog winst te behalen.
Met mijn NodeMCU (ESP8266 12E) met CP2102 usb-serial chip kom ik op
115200 kbps ~7000/s
128000 kbps ~8000/s
153600 kbps ~10000/s
230400 kbps ~14000/s
daarboven wordt het onbetrouwbaar

Bijgevoegd een wat nettere/betrouwbare versie van mijn experiment
* mdESP8266.7z (Filesize: 3.13 KB, Downloads: 235)
~ 2 million lines of BASIC