3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Reverse Engineering to Emulate Ink Cartridges for a Epson Printer

Step 4Setting Up Our Microcontroller!

Setting Up Our Microcontroller!
«
  • hello.png
  • Schematic Used.png
Start up your IDE, in my case it's MPLab, create a new project for your chip and create a basic hello world program to make sure your chip is going.

Note: My hello world program sends "Hello World!\r\n" over Serial to my computer at 38400bps

#include <p18f2550.h> // Include file specific for this chip
#include <usart.h> // USART Functions
#include <stdio.h> // printf(format,...) , sprintf(string, format, ...), etc...

#include "delay.h"

void main(){

    PORTA = 0x00;

    PORTB = 0x00;
    PORTC = 0x00;

    TRISA = 0x00;
    TRISB = 0x00;
    TRISC = 0x00;

    ADCON1 = 0x0F; // This is such a trouble maker, never forget to turn the Analogue pins back to digital! :P

    TRISCbits.TRISC7 = 1; // Turns the RX pin into an input (look it up in your datasheet for your chip)

    OpenUSART(USART_TX_INT_OFF & USART_RX_INT_OFF & USART_ADDEN_OFF & USART_BRGH_HIGH & USART_CONT_RX & USART_EIGHT_BIT & USART_ASYNCH_MODE,78);

    while(1){
        putrsUSART("Hello World!\r\n"); // Send a message via Serial

         LATAbits.LATA0 = ~LATAbits.LATA0; //Flash an LED by toggling it on and off

         DelayMS(500); // A delay function I've created
     }
}


This was set up with a 3.3V power supply because the ink cartridges run on 3.3Volts

Why a hello world program? Well, every time I set up a new project on a bread board, I always want to make sure I've got the configureation bits correct and that I'm not getting garbage in the terminal.

I think this is good practice and everyone should do it! :P

If your chip is doing something simple like mine, Great!! on to the next step
« Previous StepDownload PDFView All StepsNext Step »
1 comment
Mar 28, 2011. 11:22 PMdn_nguoiban says:
how do you control nozzles of printhead?

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
5
Followers
2
Author:NZSmartie
I'm currently studying at Massey University in New Zealand. I'm doing Computer and Electrical Engineering which is a fun course and already proving my skills to professors around the campus. I enjoy ...
more »