Sunday, October 23, 2011

Yaw Rate Gyroscope interface to PIC16F917 ( Analog-to-Digital converter Built-in Module )


In this post we will study the ADC ( Analog-to-Digital ) Module of the Microcontroller PIC16F917 . We will study a real circuit of PIC16F917 interfacing to a semiconductor Gyroscope.

The Gyroscope is a motion sensor that senses tilt in a certain direction . The used sensor is a yaw rate sensor ( free sample from Analog Devices . The Gyroscope ADXRS613 was sent in an evaluation package EVAL-ADXRS613 ) . Yaw means rotation around the vertical access . And rate means the acceleration of this rotational motion.






The output from this sensor is analog signal which represents the Yaw rate in certain direction ( Left or Right ).

The analog signals are converted in the ADC module of the PIC16F917 and are represented on a LED column according to the yaw rate and direction.



The program is very simple and straight forward. It starts by configuring the ports of the Microcontroller for input and output. Then the ADC Module is also configured ( Channel , sampling rate and result data format ).



Then the infinite loop of the program starts which contains the step of

starting the conversion ,

waiting for conversion to complete and

displaying the result on the LEDs.



When the circuit moves in clock wise direction , number of LEDs in one half of LEDs column illuminate according to the rate of change in angular motion.

And When the circuit moves in counter clock wise direction , the other half of the LEDs illuminate indicating change in direction and indicating rate of change in angular motion.





This is the Gyroscope and its datasheet file . ADXRS613









This is the circuit diagram









This is a picture of the real circuit




video



And this is a video of the circuit in motion








This is the circuit as shown on Proteus 7 simulation environment


The Gyroscope is replaced in simulation by a variable resistance because Proteus 7 does not contain a Gyroscope model.










Saturday, May 21, 2011

Gyro Horizon. Renesas RX62N Kit


In this post, we 'll show an advanced kit from Renesas based on a modern microcontroller RX62N .

I received this kit by participation in Renesas Design Contest 2010. The kit has various types of sensors and interfaces to the outer world that cannot be makes you wonder how to use them all in one application. For example, it contains a 3D accelerometer and a temperature sensor, USB , CAN , Ethernet and RS-232 interfaces and an alphanumeric LCD.



This is the Renesas RX62N Kit


The contest allows each contestant participate using only one application.

I wondered what application should I design , and I decided to design an ADI after being inspired by the Embraer 170 ADI ( Attitude Direction Indication )


This is the ADI


The ADI is an important aviation instrument that helps the pilot controlling and the aircraft. It senses and indicates Pitch ( Up and Down ) and Roll ( Right and Left ) attitude of the aircraft.




The actual ADI instrument senses the attitude using sensors in the aircraft called Gyroscope. The modern types of ADI collects attitude data from an electronic device called Laser Gyro or Fiber Optic Gyro.

My version of ADI uses a built in sensor in the Renesas kit called Accelerometer.




This is the running application on the kit ( ADI appears on the LCD )


The
Accelerometer is an electronic MEMS sensor that senses acceleration in three dimensions.

The Accelerometer senses the acceleration in three dimensions and then the RX62N microcontroller reads the data and then draws the output indication on the LCD on the kit.





This is the kit and the application on the LCD



This is the video of the kit in action.

Here is the contest entry :

http://www.renesasrulz.com/docs/DOC-1739






Monday, November 29, 2010

16F84A Stepper Motor Control


In this post , we 'll see how to control a stepper motor using the Microcontroller PIC 16F84A.


The stepper motor is a special type of motor in which motion can be controlled by speed and position. As the name complies, the stepper motor moves in steps (degrees) .

Unlike other types of motors, stepper motors have more than 2 terminals ( They can have 3 , 4 or five terminals ) .


Thus , the stepper motor is driven by switching its coils ON and OFF according to certain sequence. The function of the microcontroller is generating the driving signals.


Of course, the output current of the Microcontroller is not sufficient to drive the motor coils. There is an interfacing IC that can supply the motor coils with the suitable driving current.

This IC is ULN2003. It acts as an electronic switch opened and closed according to the output signals of the Microcontroller.






This is the real circuit connection


As you can see , I used an old hard disk drive motor. This is a three coil stepper motor. Actually it has 4 terminals ( 3 Coils and 1 Common ).








You can see the four terminals on the back of the motor



video



This video shows the stepper motor connected to the driving circuit and rotating



You can find the source code and simulation files on this link.




The simulation model shows LEDs connected to the Microcontroller 16F84A. That is because this version of Proteus ISIS does not contain a three coil stepper motor model.







This is the schematic diagram of the circuit.








Saturday, July 24, 2010

16F84 SERIAL COMMUNICATIONS



In many projects exists the need to exchange information with outside world. This case can be the need to store information from your project to a database on a standard PC or a need to communicate with another device. RS232 is widely used serial communications protocol. Modern Microcontroller chips contain hardware modules for such communications protocol. In those chips all you have to do is configuring the RS232 module and to choose the right crystal to produce the desired baud rate .



But in Microcontroller as 16F84A there is no such hardware communications modules. Serial communication can be established by software or Bit-Bang method. The standard RS232 protocol uses +12v to represent logic 0 and -12v to represent logic 1 . While TTL uses +5v to represent logic 1 and 0 V to represent logic 0.

An external IC is used as an interface between the Microcontroller and an RS232 enabled device ( PC for example ) . This IC MAX232 or HIN232 performs this level shifting function between the RS232 and TTL protocols.


Recently , I found a website implementing RS232 protocol in software using C language. The new method represented in this website is using the inverted logic ( 0v for logic 1 and +5v for logic 0 ) .

This method enables connection of the Microcontroller directly to the PC. The web page clearly explains this method . The PIC 16f8A can withstand +12v and -12v when receiving data from PC . And for data transmission to PC 0v to +5v can be distinct by the PC as two different levels.


I really wanted to try this code in real world and built the simple circuit as shown in the web page. The designer recommends connecting a resistor for PIC protection .


Of course , you can find that it is a very simple circuit that provides another new usage for the PIC 16F84A.


So how can you use the serial data form the Microcontroller ?

You can write a simple software for the PC that reads from the PC's serial port ( com1 or com2 ) . Or you can simply open the famous program Hyper terminal that comes with all Microsoft windows versions under the menu Programs --> Accessories --> Communications --> HyperTerminal. Then you need to configure the right Com port , Baud rate and Flow control . As shown here









I used a serial connector from an old mouse to connect the circuit board to the PC .





Here is the pinout of the 9 pin serial connector






This is the Hyper terminal program showing "Hello World" message from the Microcontroller .


This is the schematic drawing of the circuit




Here is the real circuit board I built and the serial connector connected to it .



Here, we 'll use the serial communication protocol RS232 to adjust the Microcontroller which in turn controls a DC motor by the PWM signals.

By choosing the motor speeds and sending them to the Microcontroller, we are able to choose PWM signals duty cycles and sending them to the Microcontroller via RS232 protocol.

The ciruit between the Microcontroller and the PC is very simple. All you have to connect is the PIC16F84A , the crystal oscillator and the RS232 9 pin female connector.

The Microcontroller is supplied by the 12V DC from RS232 pin 7 RTS. Do not be afraid of losing the PIC chip, it can withstand it without damage.

The PIC16F84A Tx pin 1 is connected directly to RS232 pin 2 Rx.

The PIC16F84a Rx pin 17 is connected to RS232 pin 3 Tx through 10k ohm resistor to adjust the input voltage to the PIC.

The motor driving part of the circuit has already been explained in the PWM DC motor control post. So I 'll use the same driving circuit.

The PWM signal comes from the PIC16F84A to the NPN 2N2222 transistor base. This transistor acts as an electronic switch.

The DC motor is driven by an external DC 9v battery.





This image shows the Proteus 7 Model of the project




As usual , you may want to try the code and the circuit om the simulator first before building it . So , you 'll find the Proteus 7 model and code in this link . But to properly send and receive data form PIC 16F84A to the virtual terminal model in Proteus 7 environment it must be configured to use inverted data . You 'll find that I configured this for the model . But if you want to see it for yourself , right click on the virtual terminal model and choose inverted .


Tuesday, July 13, 2010

16F84A VGA Output



Have you ever thought of this ?

That you can generate any kind of signals using your little Microcontroller PIC 16F84A . And one of these signals is the VGA signal that appears on your PC monitor . I thought of this idea but I couldn't implement it. But I found it at this website. So I wanted to try if it is working and share it with you.

I found an old web page containing this project
http://tinyvga.com/pic-vga . I just made some minor modification on that project and put it into a real circuit. I found that the there is a small timing issue in this software that makes the monitor flicker repeatedly.


The circuit is very simple. It consists of the Microcontroller PIC 16F84A and the 15 pin female VGA connector.



This is the schematic diagram of the circuit





This is the pinout of the VGA connector



There is a simple hint for your when downloading the software on the

Microcontroller . Make sure that the configuration is :


PRTE ON

XT

WDT OFF




I took this pictures for the monitor after running the program.




This picture shows the circuit.




video


You can see in this video the flickering I told you about.



I 'll try to fix this issue and post it when I am done with it. Now I will show you the results of the current software. I hope you enjoy it.







Here is the link for the Proteus 7 Model , source code and Hex file .