caramoan tour package

caramoan tour package

Author Topic: Arduino to PIC help...  (Read 2381 times)

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Arduino to PIC help...
« on: January 12, 2010, 09:44:48 PM »
Hi masters...gumagawa po ako ngayon ng serial interface, nagawa ko na siya sa [im]duino (bought from sir wan... ;D) and I want to create a similar program for PIC...eto po ung arduino code at sana matulungan nyo ako kung pano siya gagawin sa PIC with the same output...thanks
Code: [Select]
/*
*  ap_ReadMultiAnalog_2

*  Reads an two analog inputs and sends their values over the serial port.
*  Values are preceeded by an identifier (here letters 'A' and 'B') and after
*  each value a line break is sent.

*  This file is part of the Arduino meets Processing Project.
*  For more information visit http://www.arduino.cc.
*
*  copyleft 2005 by Melvin Ochsmann for Malmš University
*
*/

// two variables for each input pin to read and store the values
  int analogInput_1 = 2; 
  int analogInput_2 = 3;
  int value_1 = 0; 
  int value_2 = 0;

// an identifier for each value
  int id_1 = 'A'; 
  int id_2 = 'B';     

void setup() {   

// declaration of pins modes   
  pinMode(analogInput_1, INPUT);
  pinMode(analogInput_2, INPUT);

// begin sending over serial port
  beginSerial(9600);
}

void loop()
{
// read the values od the analog pins and store them in variables
  value_1 = analogRead(analogInput_1); 
  value_2 = analogRead(analogInput_2);

// print out the variables preceeded by their IDs and followed by a carriage return
// (that allows us to know where the values end and when to expect the id)
    printByte(id_1);
    printInteger(value_1);  printByte(10);
   
    printByte(id_2);
    printInteger(value_2);  printByte(10);
       
// and wait shortly to not overload the port/board?
    delay(10);
     
}


I've already tried something on proton kaso hindi gumana...huhu
eto po yung ginawa ko:
Code: [Select]
'****************************************************************
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 1/11/2010                                         *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
' Device declaration
        Device 16F877A              ' Produce code for a 16F877
        XTAL = 20                  ' Use a 20MHz crystal
        ADIN_RES = 10                ' Set analog pins
        ADIN_TAD= FRC
        ADIN_DELAY=50
        ADCON0 = %00000001
        ADCON1 = %00001111

' Declaration of serial communication
        Declare HSERIAL_BAUD  = 9600                  ' Set baud rate to 9600,19200,38400,57600,115200
        Declare HSERIAL_RCSTA = %10010000       ' Enable serial port and continuous receive
        Declare HSERIAL_TXSTA = %00100000       ' Enable transmit and asynchronous mode
        Declare HSERIAL_CLEAR = On         ' Enable Error clearing on received characters
       
' Declaration of variables
        Dim BUFFER  As Byte           ' General storage
        Dim value_1 As Word
        Dim value_2 As Word
        DelayMS 200              ' Wait to stabilize
       
        value_1=0
        value_2=0

'sending analog values
Main:
        value_1 = ADIn 0
        value_2 = ADIn 1
        HSerOut["A",Dec value_1,10]
        HSerOut["B",Dec value_2,10]
        DelayMS 10
       
        GoTo Main

galing lang po ito sa sample codes, ineedit ko lang po...
Music is my passion but engineering will be my profession...^_^!

Philippine Electronics Forum

Arduino to PIC help...
« on: January 12, 2010, 09:44:48 PM »

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #1 on: January 12, 2010, 11:14:09 PM »
Help... :'(
Music is my passion but engineering will be my profession...^_^!

Philippine Electronics Forum

Re: Arduino to PIC help...
« Reply #1 on: January 12, 2010, 11:14:09 PM »

Offline Mayalin22

  • Hydroelectric
  • ***
  • Posts: 3389
  • Pogi/Ganda Points: 402
  • Gender: Female
Re: Arduino to PIC help...
« Reply #2 on: January 12, 2010, 11:51:53 PM »
try mo nga to

Code: [Select]

' Device declaration
        Device 16F877A              ' Produce code for a 16F877
        @CONFIG_REQ
        @__config HS_OSC & WDT_OFF & PWRTE_ON & BODEN_OFF & LVP_OFF & WRT_OFF & CP_OFF & DEBUG_OFF
        XTAL = 20                  ' Use a 20MHz crystal
        ADIN_RES = 10                ' Set analog pins
        ADIN_TAD= FRC
        ADIN_DELAY=50
        ADCON1 = %10000010  ' Right justify analogue result
       

' Declaration of serial communication
        Declare HSERIAL_BAUD  = 9600                  ' Set baud rate to 9600,19200,38400,57600,115200
        Declare HSERIAL_RCSTA = %10010000       ' Enable serial port and continuous receive
        Declare HSERIAL_TXSTA = %00100000       ' Enable transmit and asynchronous mode
        Declare HSERIAL_CLEAR = On         ' Enable Error clearing on received characters
       
' Declaration of variables
        Dim BUFFER  As Byte           ' General storage
        Dim value_1 As Word
        Dim value_2 As Word
        DelayMS 200              ' Wait to stabilize
       
        value_1=0
        value_2=0

'sending analog values
Main:
        value_1 = ADIn 0
        delayms 100
        value_2 = ADIn 1
        delayms 100

        HSerOut["A",Dec value_1,10]
        delayms 10
        HSerOut["B",Dec value_2,10]
        DelayMS 10
       
        GoTo Main
Simpler designs are usually better.

Philippine Electronics Forum

Re: Arduino to PIC help...
« Reply #2 on: January 12, 2010, 11:51:53 PM »

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #3 on: January 12, 2010, 11:54:45 PM »
>>>trying... ;D
Music is my passion but engineering will be my profession...^_^!

Philippine Electronics Forum

Re: Arduino to PIC help...
« Reply #3 on: January 12, 2010, 11:54:45 PM »

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #4 on: January 13, 2010, 12:03:50 AM »
wala parin syang output ate...ginamit ko yung USART tool ng mikrobasic pang test... :'(
Music is my passion but engineering will be my profession...^_^!

Philippine Electronics Forum

Re: Arduino to PIC help...
« Reply #4 on: January 13, 2010, 12:03:50 AM »

Offline Mayalin22

  • Hydroelectric
  • ***
  • Posts: 3389
  • Pogi/Ganda Points: 402
  • Gender: Female
Re: Arduino to PIC help...
« Reply #5 on: January 13, 2010, 12:09:41 AM »
wala parin syang output ate...ginamit ko yung USART tool ng mikrobasic pang test... :'(
proven na yan sis... baka sa usart ka me problema
Simpler designs are usually better.

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #6 on: January 13, 2010, 12:12:09 AM »
hmmm...anu po kayang problema d2, UART to serial na nga ng gizmo ginamit ko para sure e... :'(
Music is my passion but engineering will be my profession...^_^!

Offline dan.enriquez

  • Diesel Generator
  • *
  • Posts: 1008
  • Pogi/Ganda Points: 52
  • Serbisyong Totoo
Re: Arduino to PIC help...
« Reply #7 on: January 13, 2010, 12:13:46 AM »
^^ang galing talaga ni IDOL COOLET na MALUPET...
"Ang Taong Walang Tiwala Sa Kapwa Ay Wala Ring Tiwala Sa Sarili" - ate mwah

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #8 on: January 13, 2010, 12:40:35 AM »
e2 po yung circuit...

Music is my passion but engineering will be my profession...^_^!

Offline tiktak

  • Gas Turbine
  • **
  • Posts: 2864
  • Pogi/Ganda Points: 204
  • Gender: Male
    • Tiktakx's Blog
Re: Arduino to PIC help...
« Reply #9 on: January 13, 2010, 01:23:34 AM »
sis gumamit ka ba ng level converter bago sa USB to serial?
8051 stuff

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #10 on: January 13, 2010, 01:35:25 AM »
sis gumamit ka ba ng level converter bago sa USB to serial?

ano po un?

napagana ko na po siya sa USART to RS232 ng e-gizmo...pero sa max232 d ko pa mapagana, ung schematic lang po sa proton tutorial ang ginaya ko... ???
Music is my passion but engineering will be my profession...^_^!

Offline tiktak

  • Gas Turbine
  • **
  • Posts: 2864
  • Pogi/Ganda Points: 204
  • Gender: Male
    • Tiktakx's Blog
Re: Arduino to PIC help...
« Reply #11 on: January 13, 2010, 01:43:08 AM »
yung max232 po yun ;D
8051 stuff

Offline Mayalin22

  • Hydroelectric
  • ***
  • Posts: 3389
  • Pogi/Ganda Points: 402
  • Gender: Female
Re: Arduino to PIC help...
« Reply #12 on: January 13, 2010, 03:22:33 AM »
e2 po yung circuit...



parang mali connection mo sis...

Dapat cguro ganito (Direct connection) as per you diagram
LCD RX ----------- Micro TX (RC6)
LCD GND ---------- Micro Gnd
LCD TX ----------- No connection


pag ayaw pa din malamang sira na tx ng pic mo, kasi nagsalubong yong tx to tx
Simpler designs are usually better.

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #13 on: January 13, 2010, 05:03:22 PM »
parang mali connection mo sis...

Dapat cguro ganito (Direct connection) as per you diagram
LCD RX ----------- Micro TX (RC6)
LCD GND ---------- Micro Gnd
LCD TX ----------- No connection


pag ayaw pa din malamang sira na tx ng pic mo, kasi nagsalubong yong tx to tx

ate gumana na po cya...

di po ako gumamit ng LCD, sa COMM port po ng computer cya nakakabit...ang ginawa ko ginamit ko ung UART to RS232 ng e-gizmo pero kapag sa max232 ayaw na po...
Music is my passion but engineering will be my profession...^_^!

Offline tiktak

  • Gas Turbine
  • **
  • Posts: 2864
  • Pogi/Ganda Points: 204
  • Gender: Male
    • Tiktakx's Blog
Re: Arduino to PIC help...
« Reply #14 on: January 13, 2010, 05:08:53 PM »
There should be no problem pag gumamit ng MAX232 parehas lang dapat ang output maka may mali din sa max232 ckt mo baka baliktad din
8051 stuff

Offline Mayalin22

  • Hydroelectric
  • ***
  • Posts: 3389
  • Pogi/Ganda Points: 402
  • Gender: Female
Re: Arduino to PIC help...
« Reply #15 on: January 13, 2010, 05:14:47 PM »
nice...  ;)

nakakalito din kasi minsan ang max232... be carefull sa tx/rx

PC RX------ < Max232 RX >TTL----------- Micro TX (RC6)
PC GND ----   Max232 GND --------------- Micro Gnd
PC TX ----- < Max232 TX >TTL----------- Micro RX (RC7
Simpler designs are usually better.

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #16 on: January 13, 2010, 05:33:43 PM »
nice...  ;)

nakakalito din kasi minsan ang max232... be carefull sa tx/rx

PC RX------ < Max232 RX >TTL----------- Micro TX (RC6)
PC GND ----   Max232 GND --------------- Micro Gnd
PC TX ----- < Max232 TX >TTL----------- Micro RX (RC7

e2 lang po connection nya? ang ginaya ko po kasi e yung sa proton tutorial...
Music is my passion but engineering will be my profession...^_^!

Offline Mayalin22

  • Hydroelectric
  • ***
  • Posts: 3389
  • Pogi/Ganda Points: 402
  • Gender: Female
Re: Arduino to PIC help...
« Reply #17 on: January 13, 2010, 05:44:23 PM »
Simpler designs are usually better.

Offline babytoybits

  • Size AA Battery
  • ****
  • Posts: 139
  • Pogi/Ganda Points: 2
  • Gender: Male
Re: Arduino to PIC help...
« Reply #18 on: January 13, 2010, 06:59:02 PM »
working na din siya sa max232...salamat ng marami ate coolet, may kiss ka sakin kapag nagkita tayo...hehe ;D
Music is my passion but engineering will be my profession...^_^!

Offline Mayalin22

  • Hydroelectric
  • ***
  • Posts: 3389
  • Pogi/Ganda Points: 402
  • Gender: Female
Re: Arduino to PIC help...
« Reply #19 on: January 13, 2010, 07:07:27 PM »
working na din siya sa max232...salamat ng marami ate coolet, may kiss ka sakin kapag nagkita tayo...hehe ;D
impakta ka wag na kiss magagalit fafah ko ;D ;D ;D

nice to help  ;D ;D ;D
Simpler designs are usually better.

Philippine Electronics Forum

Re: Arduino to PIC help...
« Reply #19 on: January 13, 2010, 07:07:27 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com