PDA

View Full Version : Simplest way to write to USB stick or TF/SD card with PBP?



CuriousOne
- 7th May 2022, 07:41
Hello.
There are numerous of SD/TF/USB stick adapter boards for hobby purposes.
I have couple of UBS stick datalogger by parallax, which are super easy to use, but they're not made anymore and were very expensive during it's time.
There are some modules for TF card, USB flash drive, which seem to have support on Arduino and other platforms. like this one: https://hallroad.org/arduino-disk-read-write-module-usb-flash-disk-for-arduino-ch376s-in-pakistan.html
So the question is, had anyone used these with PBP? which one is easiest to use in terms of resources and programming skills?
I need simple operation: Create text file with name of current time-date and write some logger data into it. That's all, no file reading, deleting, creating and so on.
So will be this doable with 16F series chips, or I'll definitely need PIC18 and so on?

mark_s
- 7th May 2022, 17:59
I didn't know these existed. I found this document which shows that it can be interfaced in 8bit parallel, SPI or UART. Which means you can probably use a pic16 for a simple data logger. A may order a couple to see how they work.

https://www.mpja.com/download/ch376ds1.pdf

CuriousOne
- 7th May 2022, 18:39
Well there are several solutions capable of doing this. FTDI has this: https://www.ftdichip.com/old2020/Products/ICs/VNC2.htm
I've bought ones made by Parallax back in 2011, and they were around $45 ea :) now prices are about 8 times lower...

rsocor01
- 7th May 2022, 22:15
I had a PBP project to write to a SD card and it worked. That was many years ago and I don't remember the details of it, but it works. Attached is the sample code that I downloaded from the internet. Just change the file extension to PBP or copy paste the code into your program.


92179217

HenrikOlsson
- 7th May 2022, 22:42
For data logging type applications I've had great success with the OpenLOG. Just send it ASCII data over a UART line and it will write it to a .txt file on an microSD card.

CuriousOne
- 8th May 2022, 15:43
Thanks!
Any sample PBP code?
for OpenLOG ?

HenrikOlsson
- 8th May 2022, 16:02
Again, for simple datalogging type applications there's really no need for any sample code. Just send it ASCII data over a UART line and it will write it to a .txt file on a microSD card. It CAN do more than that if needed, I suggest you read the documentation. Sparkfun (who I believe created (and should have all the credit) the OpenLOG) have a tutorial (https://learn.sparkfun.com/tutorials/openlog-hookup-guide/all) but I'm sure you've found that already...

CuriousOne
- 8th May 2022, 18:59
Their tutorial is quite weird.


I do need additional hardware or can hook it to say PIC16F886 directly?
Also, about Baudrate and other init options, it is not clear I need to do it each time on power up or just once?

HenrikOlsson
- 8th May 2022, 21:07
No extra hardware needed.
The easiest way is to put a config.txt, containing your desired options, on the SD card. See the Configuration File section of the tutorial.

CuriousOne
- 9th May 2022, 07:24
Thanks!
I never used serial transmission with PICs, so I need SEROUT/SERIN statements to be used, right?

HenrikOlsson
- 9th May 2022, 14:27
Yes. SEROUT, SEROUT2 or HSEROUT/HSEROUT2 is what you want.

CuriousOne
- 22nd May 2022, 18:08
I've looked at these modules and besides TX/RX they also have CTS RTS pins. Can be these handled by PBP, or I have to add some manual code like this?



HIGH RTS 'make RTS pin high
MAIN:
IF CTS=1 THEN GOTO SEND 'wait while CTS gets high, before sending the data
GOTO MAIN
SEND: 'SOMETHING

HenrikOlsson
- 23rd May 2022, 05:43
PBP command SEROUT2 can handle flow control.
With that said I've never needed to use it with OpenLOG but it depends on how much data and at what speed you you're trying to log.

CuriousOne
- 23rd May 2022, 07:35
So I just disregard these pins and let them float?

tumbleweed
- 23rd May 2022, 11:34
Look at the SERIN2/SEROUT2 commands in the manual.
They allow you to specify optional flow control pins which you would connect to the RTS/CTS pins of the module you're using if it has hdw flow control.

That may or may not work since the SERxx2 commands are bit-banged.
SEROUT2 would probably be ok, but SERIN2 might have issues.

CuriousOne
- 23rd May 2022, 16:10
Thanks, I'm only going to write to flash drive, so I'll need SERIN for just status checking, whenever drive is physically present.