USB data to FRAM

Hi folks,
I have a USB stick which contains a file of raw data (1.6kB).
I want to use a Picaxe to read this data and write it to a FRAM chip.
I am aware that the programming pins can be used to import data from the PC, usually from the Serial Terminal.
However, the Terminal seems to only use manual entry of data.
Is there another method that I can use?



Senior Member
µAL-FAT board might be the answer to this problem. Not sure about the current offerings, but the old boards they had could use spi or uart to access the file system on an SD card or USB memory.


Technical Support
Staff member
Is there a device/board that can read USB contents and be controlled by a Picaxe?
There are some USB Host modules which are intended to connect to a microcontroller which allow interfacing to USB devices.

These usually have UART, I2C or SPI interfaces. It should, I would have thought, be possible to use these with a PICAXE but I am not familiar with those modules and it may depend on the specific module.

The other alternative may be something which can run on the PC, determine the contents of the USB memory stick, which creates a program to put in a PICAXE which writes that data to FRAM. I don't know of any program designed to do that.

What format is your raw data in ?
I assume the data is in FAT32 format - it's just a standard USB stick.
I have discovered an interface board called ALFAT which may do the job - and it is available locally (Oz) also.
So, I'll look into that to see if it will do the job.



Technical Support
Staff member
I assume the data is in FAT32 format - it's just a standard USB stick.
I was more meaning what format the file which contains your data has on that memory stick; ASCII text or binary bytes. That may affect what can read the data. Some modules are only designed to read textual data files.
Sorry, I misunderstood.
The data is in the form of raw binary/bytes, comprising info to display a map on a radar screen.
It consists of screen vector info etc.
The data message file was constructed using an old DOS program and we have used some very old DOS PC's to capture it.
We look after a 1080's vintage radar display unit (ADU) in the RAAFA museum, and having a Map on the screen helps with the realism of the display.
We also show aircraft tracks that are computer generated by a DOS program on an early PC.
The early attempts of showing a Map were from a recorded cassette data tape, but that eventually became too fragile to use.
So, we found the original data listings and worked from that.
We managed to get the data onto a USB stick and now need a method of transferring it to a FRAM chip.
The ADU is under the control of a Propeller uC, which can read the FRAM contents and send it as Bisynch protocol.
It's all very interesting but can also be frustrating at times.



Technical Support
Staff member
So, if I understand correctly, the challenge is a one off, getting the data from the USB held file into FRAM. Basically a byte-by-byte copy of what was generated by a DOS program, put on cassette tape, is now on USB, which needs to go into FRAM.

I would suggest putting that data file inside a .zip file and posting that here. It should be easy enough for myself or another member to convert that into a PICAXE program which will write that data to FRAM.

I wouldn't worry about getting the PICAXE to read the USB stick; that's just extra cost and complexity when it can be done from the USB stick file and a computer program which can generate the PICAXE program to run to load the FRAM.


Senior Member
I am aware that the programming pins can be used to import data from the PC, usually from the Serial Terminal.
However, the Terminal seems to only use manual entry of data.
Using a termial is not the only way you can send data over a serial link.
If you use a windows then you can send the file over a serial COM port using the COPY command at a command prompt.

This stack overflow post gives an example of the MODE command that is used to setup the serial COM port on the PC and the COPY command that is used to send the contents of the file across that COM port
- You need to know the COM port for your USB-to-serial cable which you can get from the device manager utility
- note the extra post about using the /B flags if your data is binary


Senior Member
I have another approach you can consider which does not need a serial connection.
The M2 chips have 512 bytes for table data and the X2 chips have 256 bytes.

If you are using an X2 chip then:
Write a program that has the first 256 bytes of your data as a TABLE statement.
Loop through the table writing the data to adresses 0-255 on the ram chip

Write a 2nd program that has the second 256 bytes of your data as a TABLE statement.
Loop through the table writing the data to adresses 256-511 on the ram chip,

Thanks for the offer.
The file is 1.644 kB
The transfer rate of the serial connection is normally 4800bd.
FRAM writes can occur at clock speed (no delay).
Can we do a direct "read in to store FRAM" without crashing due to program overheads?
In other words, will the "read in" be too fast to allow correct transfer?

The other thing is the file size - there is insufficient memory in a Picaxe to store it in one hit, so the data would need to be split into multiple batches.

So, how would you do it?

Thanks for that info.
I had forgotten about the old Copy method.
Your proposal would require a method of connecting the USB stick to the Picaxe - an interface board.
To get one involves some costs, which we tend to avoid.



Senior Member
At work I used VBscript to send commands from an Intel ComputeStick (tiny Windows 10 computer) to a COM port (an FTDI USB to serial converter) to turn off/on some TVs.

I believe you can probably use VBscript to read in your file and send it to the COM port.
'turn TV power on using the serial port (Sharp PN-LE601/701/801 models)
on error resume next
'Tristate Constants: -1 = true, 0 = false, -2 = use default
Const ForWriting = 2, TriState = -1 
Dim fso, f

Set fso = CreateObject("Scripting.FileSystemObject")
'WScript.Echo " fso: " & Err.Number & " " & Err.Description & "."

Set f = fso.OpenTextFile("COM4:9600,N,8,1",ForWriting,TriState)
'WScript.Echo " open comm port: " & Err.Number & " " & Err.Description & "."

'wait 1.5 minutes after PC start to power on the TV
WScript.Sleep 1000    

' Write data to the port: MNRD1[ ][ ][ ][CR] (show model name)
f.Write Chr(77) & Chr(78) & Chr(82) & Chr(68) & Chr(49) & Chr(32) & Chr(32) & Chr(32) & Chr(13)
WScript.Sleep 1000

' Write data to the port: RSPW1[ ][ ][ ][CR] (enable power on when sleeping)
f.Write Chr(82) & Chr(83) & Chr(80) & Chr(87) & Chr(49) & Chr(32) & Chr(32) & Chr(32) & Chr(13)
WScript.Sleep 1000

' Write data to the port: POWR1[ ][ ][ ][CR] (power on TV)
f.Write Chr(80) & Chr(79) & Chr(87) & Chr(82) & Chr(49) & Chr(32) & Chr(32) & Chr(32) & Chr(13)
'WScript.Echo " write data: " & Err.Number & " " & Err.Description & "."

'WScript.Echo " Close: " & Err.Number & " " & Err.Description & "."


Senior Member

you said
Your proposal would require a method of connecting the USB stick to the Picaxe - an interface board
I didn't make myself clear enough about the COPY method. It does _not_ require the USB stick to be connected to the PICAXE. The file needs to be on the PC, either on the plugged in USB stick or copied off the USB stick onto the PC C: or D: drive.
- Write a PICAXE program that reads bytes from a serial connection and writes them to the FRAM chip. This sounds exactly like the program you intended to write in your original post.
- Connect the PC and the PICAXE with a USB-to-serial cable. Your PICAXE program will be reading the characters that are sent across this serial connection..
- Plugging the USB-to-serial cable into your PC will cause a virtual COM port to be created on your PC. You can find the COM port number from device manager.
- Start a command prompt on the PC
- Use the windows MODE command to open this virtual COM port on the PC side with the correct baud rate, 1 stop bit and no parity.
- Copy your file on the PC to this open COM port using the windows COPY command. This will cause your file to be sent over the serial connection from the PC to the PICAXE.


Technical Support
Staff member
So, how would you do it?
How have I done it would be a better question.

I have a PC program which reads the bytes from the file on a PC, generates one or more PICAXE programs which puts the data which was in the file to FRAM. Just download and run the first program into a PICAXE, wait for the "Done" message, download and tun the next. When finished the FRAM will hold a copy of what was in the file.

One could probably put all the data in one PICAXE program if using an X2 which has 4096 bytes of program memory, even an M2 with 2048, but, if not, then it will have to be more than one PICAXE program.

Zero cost, no messing about with complicated PICAXE programs, serial connections or anything else.

All it is waiting for, to give you the PICAXE programs you need, is for you to supply the raw data file.
We have to delay sending the file to you because the USB stick is currently in the possession of one of our group from the museum.
As soon as we recover it, we'll send a copy to you.
It may be a few days I think.
Will a 14M2 or 18M2 do the job?(memory)

I have now managed to recover the raw data file we need to be stored in FRAM.
The file was generated many years ago by a DOS program.
It is attached in .zip format.
Your move!



I know nothing about Python, but I can see what you have done here.
I'm checking the data against the original, and if OK will proceed with testing the programs.
Thanks for your effort on this.



Technical Support
Staff member
Glad you are following the Python code okay. It's a bit thrown together because I thought it would be worthwhile adding other functionality which might be needed for similar things in the future, and thought it best to do that now while I can remember what I am doing and how I did it !

The big limitation at present is it only reads binary files, not ASCII raw hex, S-record and similar files. I'm thinking on how best to add that.

It appears to give valid output when I tested but I only did a limited amount of testing so if you spot any oddities or anomalies; let me know and I'll take a look at them.
The programming went well - all the data ended up in the FRAM.
I passed your Python program on to one of our group who dabbles in that language.
He has taken it away for further study - not my area I'm afraid, I tend to stick with Basic and Spin.
Thanks again for your response.

Ken Mac