Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Write PIC data into matlab serially

Status
Not open for further replies.

mankmanky1

New Member
how would you write a pic program in picc18 compiler for a pic18f4431 in mplab to send the letters ‘G’ and 'A' to matlab at 9600 bps serially? All I can send with the code below is the letter 'K' a million times to matlab...

Thanks

#include <htc.h>
#include<pic18.h>

void delay()
{

for (int j=0;j<30000;j++)
{
}

}


void main(void)
{
//int i=0;
//BAUDCTLbits.BRG16=0;
//SPBRG = 0b01000000;
TXSTA =0x24; // TX enable BRGH=1
TRISC=0b10000000; // RX
RCSTA=0x90; // continuous RX
delay();
while(1)
{

TXREG = 'K';
delay();
wait:
if(TXIF==0 )
{
goto wait;
}

break;
}



}//END MAIN
 
Hey man,

Yeah it helped me ultimately to write data from matlab to the pic, however, i cant seem to write from the pic to matlab... If you know of how to correct my code, please let me know...

Thanks
 
i have only sent it to com port adn that too not with matlab.I guess any of the PIC gurus here can answer that!
 
actually there are many! i think only the 'Matlab' word turn them off.Start a new post and be a bit more general like 'How do i control the computer with the PIC,that would not give you any specifics on matlab but at least you will know how data is sent to a specific software such as take LAbview i bet many have worked with it. A liitle work and you will be able to convert it for matlab!


PS:If any body else is reading this post then cna i ask whether Quantiphi(a blockset of simulink 3rd party) offers a trial version cause i have made a temp controller in statelfow which according to the Quantiphi people can convert it on to PIC18 code but i dont have access to it even in college much less at home!It costs 2grand and i dont have that kind of money(atleast for a Blockset)
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top