Dare2Tech
  • Home
    • Electronics
    • About
    • Contact
  • Electronics
    • PIC32 Topics
    • Transistors
  • About
  • Contact
  • Home
    • Electronics
    • About
    • Contact
  • Electronics
    • PIC32 Topics
    • Transistors
  • About
  • Contact

PIC32 Remote Control Car

8/8/2015

0 Comments

 
This is a short overview of the components used to make yourself a remote controlled car using a PIC32 microcontroller.

Have you ever wanted to make and control your own car, see below for the components used. In the future I will go over an in depth tutorial with schematics of the connections.

Items used:
  • PIC32 microcontroller
  • Power source
  • L293D Push-Pull 4-Channel Driver
  • XL6009 Step-up module
  • Four Arduino wheels
  • Breadboard
  • Several jumper wires
  • Some rubber bands
  • Some cardboard
  • My PIC32BTN Android application
  • HC-05 Bluetooth Module

Most of the items used I found on eBay for fairly cheap. The power source I used was a 5 volt 10,000 mAh power bank that was then boosted to 6 volts using the step-up module which would power the car for several hours of fun. Seen in the video and photos I used my MAKEmicro32 microcontroller board seen plugged in the breadboard.

See my contact page to request the code I used or if you would like me to put together the in depth tutorial with schematics for a guide to connect everything together.


Disclaimer - About Page

0 Comments

PIC32 Pull-Up and Pull-Down(*)    Internal Resistors

8/1/2015

0 Comments

 
Click the above photos for details.

Have you ever used a resistor with a button on a breadboard so you can use the button to control something when the button was pressed or not pressed, with internal resistors on the input of your microcontroller you can avoid needing that resistor on the breadboard. This is a simple tutorial to demonstrate the use of an internal pull-up resistor seen on the left button in photo and an internal pull-down resistor seen on right button in photo that are internally available on a PIC32 microcontroller input pin, this example demonstrates them being used with a button to turn on or off an LED on each side of the microcontroller.

Example internal pull-up resistor code:
  pinMode(3, INPUT_PULLUP);

Example internal pull-down resistor code:
  pinMode(17, INPUT_PULLDOWN);

To read the current value on the input use:
  digitalRead(3);
  or
  digitalRead(17);

See the attached file for the complete code example using each one, an internal pull-up and an internal pull-down resistor. The way the code is written is that when the input pin reads high (3.3 volts) the LED is on and when the input pin reads low (0 volts) the LED is off.

Note (*) : Some of the PIC32 microcontroller versions only support internal pull-up resistors on I/O pins, so be sure to reference the datasheet if you are trying to use internal pull-down resistors on input pins. This code example is using a PIC32MX250F128B microcontroller which has both pull-up and pull-down internal resistors available to be used. Checking the datasheet for the PIC32MZ and PIC32MX1XX/2XX microcontroller versions, they have pull-up and pull-down internal resistors available.
pic32_internal_pullup_pulldown_example.pde
File Size: 1 kb
File Type: pde
Download File

Disclaimer - About Page

0 Comments

PIC32 using Transistor as Switch LED

6/30/2015

0 Comments

 
Picture
Click to enlarge image
A microcontroller pin has a limited amount of current you can supply which is typically enough to light up one LED at a time. For instance the PIC32MX250F128B microcontroller the absolute maximum current drawn by any I/O pin is 15mA referencing the datasheet. By using a transistor you can increase this amount significantly, the PN2222A is capable of sinking up to 450mA and the IRLU024NPBF is capable of sinking 15A. You can even control higher voltages then your microcontroller pin could normally handle as well.

This example will demonstrate using two different transistors to switch on and off several LED's from one I/O pin. This example is sinking around 200mA of current for the eight LED's connected to each transistor. The setup used in this demo draws under 6mA of current from the microcontroller pin when using a PN2222A transistor and basically 0mA using a IRLU024NPBF. I purchased the transistors from Tayda Electronics, making the  IRLU024NPBF sixty-five cents and the PN2222A five cents each.

Items used:
1   PIC32MX250F128B microcontroller board
9   White LED's with 220ohm resistors
2   830 point Breadboards
2   470 OHM resistor (one for each transistor)
1   PN2222A transistor
1   IRLU024NPBF transistor
Some black 22AWG solid wire
Some red 22AWG solid wire
A few jumper wires

PN2222A pinout photo can be found here:
http://bit.ly/1C6FxQz

IRLU024NPBF pinout photo can be found here:
http://bit.ly/1eYSJg0

See the video below for a demo of it being controlled by a PIC32 microcontroller and a simplified version of the circuit schematic connections to each of the different transistors used.

Direct video link: https://youtu.be/6XEnEG-1PdQ
Disclaimer - About Page

0 Comments

Bluetooth HC-05 or HC-06 Tutorial with PIC32

6/20/2015

0 Comments

 
Picture
This is a simple starter tutorial to work with a Bluetooth module (HC-05 or HC-06) using the PIC32BLUE Android application (you can use PIC32BLUE+ and/or PIC32BTN apps instead too depending on which example code you are using that is attached below).

Materials used:

1) One Microcontroller (PIC32MX250F128B)

2) One Bluetooth module

3) Four jumper wires (male to female)

4) Power source (10,000 mAh power bank battery pack 5volts)

5) Android phone/tablet with PIC32BLUE installed (device must have Bluetooth capability)

 
Important note, the Bluetooth module power source and inputs should be at 3.3 volts only. VCC on the Bluetooth module should be connected to 3.3 volts and GND should be connected to ground seen in the photo.


The power bank is optional and can be switched out with power source and the jumper wire connection style may vary depending on the connectors available on your microcontroller board to make the necessary connections.

Connections between the microcontroller pins to the stepper motor PCB are as follows:

Bluetooth Module <----to----> PIC32 Microcontroller Pin

         RXD   <--------------wire------------>   TX

         TXD   <--------------wire------------>   RX

Note: RX means receive and TX means transmit, so the Bluetooth module will transmit to the microcontrollers receive pin and vice versa.

Note2: You may want to change the code attached in this post to use a different serial port, so you will want to replace the word “Serial” in the code to either Serial0 or Serial1, etc according to the pins you would like to connect to.


A quick and easy way of replacing all of the ‘Serial’ words with a few quick steps is the following:

When in MPIDE with the code sketch opened, hold down the “ctrl” (control) key on your keyboard then press the “F” key, a pop-up will show, you can then type the word Serial inside the “Find:” section and type the word Serial0 (or whichever one you wanted to use) into the “Replace with:” section, once both sections have what you wanted to change click on the “Replace All” button and all the changes have been made throughout the code example.


The connections will vary according to the microcontroller board you are using so be sure to check your datasheet or board’s manual for pinouts to ensure you are connecting to the correct pins. You can also navigate to where you have the MPIDE folder installed on your computer then follow the following file path below to see all of the available board folders then select the folder for your current board and reference the Board_Defs.h file, scrolling down in that file until you see the “Serial Port Declarations”. Note: as soon as the softwareSerial library is added into MPIDE I will be sure to update this post with an example using softwareSerial for an easier connection/wiring example with consistent pin number connections between board selections.


Windows file path example below once inside the MPIDE folder on your computer:

***\hardware\pic32\variants\...


For using the DP32 board settings I used the following connections and changed the provided code to use Serial0 :

Bluetooth Module <----to----> PIC32 Microcontroller Pin

         RXD   <--------------wire------------>   14

         TXD   <--------------wire------------>    6

Five different code examples attached below. Be sure to read through them and choose which one fits your needs the best. They are listed as the easiest first to the hardest last.
hc05_or_hc06_simple_echo_with_delay.pde
File Size: 0 kb
File Type: pde
Download File

hc05_or_hc06_simple_echo_without_delay.pde
File Size: 0 kb
File Type: pde
Download File

hc05_or_hc06_with_delay_toggle_led_simple.pde
File Size: 0 kb
File Type: pde
Download File

hc05_or_hc06_delay_toggle_leds.pde
File Size: 1 kb
File Type: pde
Download File

hc05_or_hc06_without_delay_toggle_leds.pde
File Size: 1 kb
File Type: pde
Download File

Disclaimer - About Page

0 Comments

Stepper motor (28BYJ-48) Tutorial

6/12/2015

0 Comments

 
This is a simple starter tutorial for the 28BYJ-48 stepper motors as seen in the pictures above which may come with different looking PCB’s, but function the same.

Materials used:

1) One Microcontroller (PIC32MX250F128B)

2) One 28BYJ-48 stepper motor with ULN2003 PCB

3) Four jumper wires (male to female)

4) Two jumper wires (female to female)

5) Power source (10,000 mAh power bank battery pack 5volts)

The power bank is optional and can be switched out with any 5 volt power source and the jumper wire connection style may vary depending on the connectors available on your microcontroller board to make the necessary connections. You will want to be sure that the power source can provide well over 200mA or 0.2amps since it will be required for the stepper motor and your microcontroller current requirements.

For the code examples attached I used the digital pins 13,12,11,10. You can use any digital pin, just make sure you change it accordingly in the code example attached if you do. This was put together using MPIDE for PIC32 microcontrollers, but the code will work with Arduino or similar microcontrollers as well.

Connections between the microcontroller pins to the stepper motor PCB are as follows:

Stepper motor PCB <----to----> PIC32 Microcontroller Pin

         IN1   <--------------wire------------>   13

         IN2   <--------------wire------------>   12

         IN3   <--------------wire------------>   11

         IN4   <--------------wire------------>   10

   

The plus sign on the stepper PCB will be connected to 5 volts (red wire in front on photos) and the minus sign will be connected to ground (black wire in front on photos). Also, depending on the stepper motor PCB the plus sign and minus sign might be located behind or in front of the pin connectors.

On the stepper motor PCB make sure that there is a jumper on the two pins closest to the resistors as seen in the photo near the 5 volt input connection. Sometimes depending who you purchase the stepper motor from, the jumper might be missing, the jumper is needed in order for it to function (the black jumper/connector seen in photo).

If you’re interested in a detailed video explanation of how stepper motors work, I recommend this one: http://bit.ly/1MeFP7N

Picture
stepper_motor_tutorial_simple.pde
File Size: 2 kb
File Type: pde
Download File

stepper_motor_forward_then_backward.pde
File Size: 2 kb
File Type: pde
Download File

stepper_motor_tutorial_no_delay.pde
File Size: 2 kb
File Type: pde
Download File

Direct video link: https://youtu.be/EOM6aipshaI
Disclaimer - About Page

0 Comments

chipKIT Pi (or DP32) vs Uno digitalWrite Frequency

6/7/2015

0 Comments

 
If anyone has ever wondered what the max frequency for the chipKIT Pi (or chipKIT DP32) is compared to the Arduino UNO using digitalWrite(), check out the differences below:
Picture
This was taken using the Analog Discovery™ using WaveForms™. The PIC32 is on top and the Uno is on the bottom in the image.

PIC32 frequency on average is roughly around 403.23 kHz (PIC32MX250F128B).

UNO frequency on average is roughly around 128.87 kHz (ATmega328).

The PIC32 has roughly a 3.13 times faster frequency than the UNO using the digitalWrite() function.

This test used the following code segment below for both:

#define pin_Toggle 13

void setup() {
  pinMode(pin_Toggle, OUTPUT);
}

void loop() {
  while(1)
  {
    digitalWrite(pin_Toggle, HIGH);
    digitalWrite(pin_Toggle, LOW);
    digitalWrite(pin_Toggle, HIGH);
    digitalWrite(pin_Toggle, LOW);
    digitalWrite(pin_Toggle, HIGH);
    digitalWrite(pin_Toggle, LOW);
  }
}
Disclaimer - About Page

0 Comments

Pinout Printout chipKIT PI and DP32 - PIC32MX250F128B

5/31/2015

0 Comments

 
Here is a printout that I put together to be able to tape on top of your microcontroller to display the pin numbers according to your board settings chosen while programming, either the chipKIT Pi or the DP32 (both use the same microcontroller).

This is also perfect for people that are building their own DIY PIC32 board found in this link below:
http://chipkit.net/diy-chipkit-board/

Your can print them on one page or print them double sided selecting 'flip on long edge' so you can just cut the paper in half saving paper. The chipKIT Pi version is on the first page and the DP32 version is on the second page. Print it out, cut it, and tape it on.

If requested I can put this together for other boards and/or I can make a colored version that I am currently working on to help decipher PWM pins, analog pins, voltage inputs, and ground.

Printout Key:
R = MCLR
V = VDD = 3.3v
G = VSS = GND
C1 = OSC1 = crystal oscillator
C2 = OSC2 = crystal oscillator
T = Tantalum capacitor 10uF (positive side)
B = VBUS

L = Bootload LED output (blinks when in bootloader mode)
P = Program/Bootload button input pin

Hope someone finds this useful.

See the image attached below as an example and the PDF file to print as well.
Pinout Printout chipKIT PI and DP32 - PIC32MX250F128B
pinout_pic32_three_boards_makemico32_&_dp32_&_chipkit_pi.pdf
File Size: 101 kb
File Type: pdf
Download File

Disclaimer - About Page

0 Comments

Change 14 pins all at once - pic32

5/31/2015

0 Comments

 
Most of the time you would simply toggle one pin at a time on a microcontroller, but each pin takes its own small amount of time to be turned on. Using the code below you can change the state of 14 pins at the same time with a max frequency of 5Mhz all at one time.

If you want the fastest way to turn on a pin see the following code below. This simultaneously turns on 14 pins and then off 14 pins using a PIC32MX250F128B microcontroller.


// PIC32MX250B128F microcontroller
//using DP32 board setting in MPIDE or UECIDE

void setup() {   
  delay(2500); 
  // sets pins 0-8 as outputs and turned low
  for(int i = 0; i<9; i++)
  {
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);    
  }
  // sets pins 11-14 as outputs and turned low
  for (int i =11; i<15; i++)
  {
    pinMode(i, OUTPUT);
    digitalWrite(i, LOW);
  }
  // pin 17
  pinMode(17, OUTPUT);
  digitalWrite(17,LOW);

}

void loop() {
  while(true)
  {
    LATB |= 0xEFBF;
    LATB &= 0x0000;
  }
}
Below is a screenshot using a logic analyzer to see all 14 pins changing at the same time on the PIC32MX250F128B microcontroller.  This was taken using the Analog Discovery™ using WaveForms™.
Picture
Picture
Disclaimer - About Page

0 Comments

Ways to Toggle digital pin

5/26/2015

0 Comments

 
There are many different ways to toggle a digital pin on a PIC32 microcontroller using MPIDE or UECIDE.

I will be going over a few different ways available and then going over the details for each if there is any interest in a complete code example to run.



1)    digitalWrite(14, HIGH);
       digitalWrite(14, LOW);

2)    LATA |= 1;
       LATA &= ~1;

3)    LATAbits.LATA1 = 1;
       LATAbits.LATA1 = 0;

4)    digitalWrite(14, ~digitalRead(14));

5)    digitalWrite(14, !digitalRead(14));

6)    LATAINV =1;

7)    LATASET=1;
       LATACLR=1;

Do you have a favorite way to access a digital pin or another way not listed?

Feel free to leave a comment below.
Disclaimer - About Page

0 Comments

    Author

    I'm a Computer Engineer with passion for hardware & software.

    Categories

    All
    PIC32
    Transistors

    Archives

    August 2015
    June 2015
    May 2015

    RSS Feed

Electronics
About
Contact
Mobile Site