2016年6月26日 星期日

Host interface

There are many ways to display data to end users. The first one is to show data on a 7'' LCD panel for BBB, the second one is to pass the data to a PC and display the data on computer screen. I chose the second for my bad eyesight.
Few articles back I mentioned about Qt and network, now, I combine all the previous results together to display the final outcome. The data acquisition procedures are:

  1. Qt program sends operation mode command to BBB through UDP. 
  2. Convert audio data by WM8731 ADC then save to SRAM through FPGA.
  3. Once SRAM is full, FPGA generates a hardware interrupt to AM335X. 
  4. AM335X starts reading data from SRAM through GPMC. 
  5. When reading is done, AM335X starts sending data to PC through UDP. 
  6. Qt program captures and displays the received data. 
The final Qt program is shown below.


2016年6月10日 星期五

9 Axis sensor system

I found a 9-Axis sensor module few months ago when I was moving and packing up my stuff. I used the module on my Cortex-M3 STM32 MCU development board Now I am thinking to plug the module to my BBB and turn my BBB to a sensor system board. 
Here is the main features of the my sensor module:
  • Analog Device ADX345 3-Axis accelerate-meter sensor
  • ST L3G4200 3-Axis angular velocity sensor
  • HoneyWell HMC5843 3-Axis magnetic field sensor
  • BOSH BMP085 pressure sensor 
All the sensors on this modules implements I2C interface, what I need to do for my BBB is to find a 3.3V power for the module and turn on the I2C interface on Linux. The I2C addresses of above sensors are 0x53, 0x69, 0x1E and 0x77 respectively. I pick up I2C-2 on BBB for no obvious reason, I2C-1 should be find as well. I2C-2 is pin 19/20 on BBB header 9. 

Communication with Qt

For days, I had been working on how to establish communication between BBB and my Windows PC through Ethernet, I had little experience programming a PC side software, after scratching my head and surfing through the Internet, I pick up Qt for its rich resources. I planed to have a thread in Qt to wait for incoming data from BBB, but I realized the way Qt uses a terminology called "signal and slot"; a simple way to put this is "a incoming signal trigger the slot to do a task".
Here is the example of how Qt link incoming Ethernet signal to a function, "readyRead" is the incoming signal while rxPacket is the function to process the UDP packet when triggered.
connect(udpSocket, SIGNAL(readyRead()), this, SLOT(rxPacket()));
Below is the snap of my Qt data acquisition interface, I will explain the functions of program later.
 

2016年5月25日 星期三

UDP connection programming

Although I plan to use BBB as my embedded host, I want to transfer data from BBB to my host PC as well for one major reason; data verification and display. Simply because coding on desktop computer is easier to setup and rich ready to use library can be used to display my data. 
There are many ways to communicate with BBB such as TCP/ UDP, USB, UART, I chose UDP to be my main communication method for its simplicity and speed. UDP libraries are already in GCC, allI have to do is to implement the libraries.  

You just have to put the data pointer, number of bytes to be sent and destination IP address, the data will be sent from BBB to PC. 

size_t udpTXClient(const void *bData, int nSize, char *IP){
struct sockaddr_in serv_addr;
    int sockfd, i, servLen;
size_t nTxLen; 
size_t nWriteLen; 
    if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0))==-1)
        err("socket");
servLen = sizeof(serv_addr);
    bzero(&serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = inet_addr(IP);
    serv_addr.sin_port = htons(1111);
//printf("UDP sender enabled\r\n") ;
if((nTxLen = sendto(sockfd, (void *)bData, nSize, 0, (struct sockaddr *) &serv_addr, servLen))==-1)
printf("UDP TX client fail\r\n");
    close(sockfd);
return nTxLen; 
}


2016年5月14日 星期六

GPMC registers setup

A quick snap of my GPMC registers setup on AM335X, I reconfigure the register values through Kernel Module programming and display the value by using prink. The the signal analyzer diagram from my previous article is the result of this setup.

GPMC logic analysis

After struggling a bit (actually a lot), I manage to extract data from BBB on FPGA, the following graph is the output captured by Quartus II SignalTap2 analyzer. Here I use multiplexed mode in GPMC to conserve GPIOs, this means that address and data are share the same signal path.
The second graph is the timing diagram I copied from AM335X datasheet, address is latched into FPGA on rising edge of ADVN signal, then data is latched or send on falling edge of wen/ oen signal.
At the stage, I have basically connect my BBB to FPGA successfully which means my Linux OS is able to control external device to perform different hardware functions.





















2016年5月9日 星期一

Hardware connection

Finally, have my PCB ready and beaglebone black connect to my DE2-115 board. After connecting BBB to DE2-115, both boards can be booted on successfully!! I have checked some basic functions of BBB such as Ethernet, Uart and I2Cs, works fine at the stage.
Now, the challenge is waiting ahead, I have write a GPMC driver to port BBB to DE2-115, a Linux AP program to interface with PC and verilog for FPGA digital logic.

2016年4月2日 星期六

GPMC interface

Below is my design of GPMC bridging schematic that would connect P8/ P9 header of BBB to DE2-115 JP5 header, This is the easy part when I was trying to port GPMC on BBB, everything is very straightforward.

2016年4月1日 星期五

P8/ P9 interface and DE2-115

I plan to use mux. GPIOs on P8/ P9 headers to GPMC then connect BBB to DE2-115, I have explained how P8/ P9 can be configured to GPMC module, I will emphasize more on DE2-115 FPGA development board.  
DE2-115 is Altera's official development board, the core of the board is Altera's Cyclone IV FPGA. DE2-115 contains peripheral devices such as SDRAM, LEDs, 7-Segment display, switches, on-board memory, USB, Ethernet etc. for designers to verify their designs, it is an excellent cost effective prototyping board. 
Beside rich development resources, the biggest reason why I choose DE2-115 as my hardware platform is that the board has expands the spare GPIOs to expansion headers so I can use the headers to interface P8/ P9 headers on BBB. Once the header is connected to BBB, I can use BBB as system master to issue commands to FPGA and control peripherals on the development board. 
The setup can fully use the advantages of FPGA and AM335x, in my design, FPGA is designated to parallel computing while AM335x is in charge of task scheduling and software processing.  

2016年3月20日 星期日

BBB interface expansion

High speed data acquisition cannot be made possible without a customized hardware system connected to a cpu like AM335X.  In my previous article, I mentioned about GPMC interface that can be used to interface with FPGA, the customized hardware system can then be implemented by FPGA for high speed data acquisition. 
GPMC function can be multiplexed from P8/ P9 expansion headers on BBB, However some of those GPMC pins are already used by eMMC, therefore, a small modification of BBB is required.
I removed the pull-high resistors of the eMMC pins so that the pins can be multiplexed to GPMC. Linux will have to be boot from SD card since eMMc function is altered by GPMC. Get familiar to remove 0402 sized resistor. 

2016年3月17日 星期四

Parallel interface

After careful studying of AM335X datasheet and spent tremendous hours on  internet. I found a function called General Purpose Memory Controller(GPMC) by AM335X can provide excellent communication protocol to interface external devices, in my case, FPGA.
It is really not an easy task to understand all the GPMC features, I snapped the block diagram from the datasheet for a quick overview of GPMC.                               
Basically, I use GPMC address bus as my register location on FPGA and GPMC data as my register value, so every time I issue a command from AM335X to FPGA, my FPGA will receive the corresponding instruction to be decoded. 
Once I am able to activate GPMC on AM335X, I will be able to interface BBB to my Alter's DE2 development board.
            



2016年3月13日 星期日

From hardware to software

Through my careers, I had worked on different electronics engineering jobs. Each of them requires different  skills, tools technologies. I used to design electronics circuits, translate the circuits to actual printed circuit board, synthesize HDL (hardware description language) for high speed data acquisition algorithm, MCU/CPU (mciro/ central controller unit) coding for hardware system control, writing server test program on PC site.
I am particularly interested in digital logic design in FPGA and embedded system, each of the technologies serve for different purposes, e.g. I used FPGA for high speed data acquisition and DSP (digital signal processing) and MCU for hardware system control and data communication. It is not easy to used one of the above technologies to replace another one. I have been thinking connect an embedded system to FPGA so that advantages of both technologies can be combined together. So you know I have a big picture here now, connect a CPU to FPGA, so that our work can now be extended to customized peripherals.  Of course BBB is the centre of my big picture. 

2016年3月12日 星期六

Reasons for BBB

Yet, the main hardware features of BBB can be find on https://beagleboard.org/black. The reasons I love BBB to be my choice of electronics projects are:
1. Powerful hardware; the core of BBB is a ARM Cortex-A8 processor which is the most powerful embedded development board cpu I can find on market.
2. Affordable; less than $50 US, the choice for every budget tight developer.
3. Open hardware; all the hardware information (schematics, PCB) is available, easy for hardware customization.
4. Open software;  supported by various open source Linux and Android system, developers can custom the source code to fit their designs.
5. Standard C library support; so I can program BBB just like program a standard windows PC.
6. Connectivity; UART, I2C, GPIO expansion, USB, Ethernet, you name it.
7. GPIO expansion; of course very important if you want to extend BBB to your imagination, this feature is particularly important for my project.

2016年2月9日 星期二

I am an EE hobbyist, the blog is to show my working result on the project I am interested in. The development board I am recently working is Beaglebone Black, interesting tricks can be found if you dig deep into the open source hardware/ software system.