USB data logger project using pic-microcontroller




Introduction:

In this project, PIC 18F4550 is programmed to perform the function of an oscilloscope. Communication is set up between the computer and the PIC through USB, so that bulk data transfer mode is implemented. Analogue circuits are carefully designed so the user can select gain and offset on the computer screen and have the circuit perform the corresponding functions. Also software based calculations like FFT and cursor information can be displayed on the screen. It is also possible to copy and paste the plot to notepad directly.

USB data logger project

Hardware Design:
The goal of the hardware is to let the user select offset and gain from the computer user interface rather than twisting a little potentiometer. The design is shown in Graph 1 below. The computer enables the DAC and puts an 8-bit number onto the DAC data lines. The DAC output is sent to the “‘+”‘ input of the first op-amp, providing an offset.

he second op-amp sets up the gain stage. There are four sets of resistors. A multiplexer is used to select one set only at a given time. The value of R_1 and R_2 sets up the gain provided that the “‘+”‘ end is set at 2.5V. To mimic a real oscilloscope, we chose four options for the gain: 0.1, 1, 10, and 100. Capacitors that are parallel to the resistors right before the output stage set the high frequency cutoff of the circuit. The high frequency cutoff is set to be around 4kHz. This is lower than twice the fastest sampling frequency the circuit can perform, and thus eliminates aliasing problems. The schematic for the circuit is shown in Graph 2 below.

It is to be noted that this is the circuit for one oscilloscope probe. Since we have two channels, the same circuit is supposed to be repeated twice. However, due to mistakes made in a long soldering session, one of our TLC7524Cs got destroyed. Luckily, we had another DAC called AD558. It works a little differently than TLC7524C. The output range for AD558 is [0-2.56V] other than [0-5V]. An additional times 2 multiplier op-amp is added after AD558. The circuit is shown in Graph 3 and schematic in Graph 4 below. The bill of material for ordering from Farnell is attached as Graph 5 below.

Communications Protocol:
We are using the 8-bit configuration for the ADC inside the microcontroller, because it offers a good tradeoff between conversation time and resolution.

Bulk data transfer mode is used for transferring data through USB. 256 bytes of data is sent every time through USB. (This is the upper limit we measured.) There are in total 40 lots of 256 bytes. Taking into account 40 bytes as command bytes, (for every 256 bytes, there is one command byte) we end up with 10,200 bytes of data, (256×40-40=10,200) of which we display 10,000. Data is transferred very efficiently this way.




The added communication commands are summarized below:
GET_ADC_COMMAND(command byte is 0xAA)
Software interface sends: {0xAA, channel number}(2 bytes)
Hardware returns: {0xA
A, input data}(63, 64, 64 bytes)

READ_COMPARE(command byte is 0xBA)
Software interface sends: {0xBA, channel number}(2 bytes)
Hardware returns: {0xAA, CMCON register, input data}(3 bytes)USB data logger project

SET_PROPERTIES(command byte is 0xCA)
Software interface sends: {0xCA, compare value, channel 1 offset, channel 1 gain, channel 2 offset, channel 2 gain}(6 bytes)
Hardware returns: {0xAA}(1 byte)

Firmware Design:
A flow chart for firmware can be found in Graph 6 below.

The hardware specification is shown in Table 1.

Sampling frequency 16kHz
Input frequency range [2Hz-4kHz]
Input voltage range [0V-5V]
Resolution 9.78x 10^(-3)V
Gain [0.1-100]

 

For more detail: USB data logger project




Current Project / Post can also be found using:

  • pic microcontroller based usb data logger
  • temperature data logging using pic proteus design
  • data logging system proteus implememtation and code
  • datalogger usb pic

Leave a Comment

*
= 3 + 1

Read previous post:
XBee radio communication between PICs using pic-microcontroller

Overview Typically, two pics communicate by RS-232, a wired transmission. However, it may be desirable to communicate via a wireless...

Close
Scroll to top