Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Pic18F4450 + RS232 + basic

Status
Not open for further replies.

orphee

Newbie level 4
Joined
Oct 1, 2009
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,332
Hi

I made an application for my small electric motorcycle who works
( http://www.motoelectrique.unblog.fr ) but with a PIC16F628A who was my first PIC application.
In fact I have two separated systems: a PIC16F628A control system and an "cycle analyst" module, who can send a string using serial port (containing speed, distance, power...)
Now I'm trying to make this: cycle analyst -> control system -> Oled display module (4DGL) .
I tried to catch cycle analyst string (so using my Pic16F628A) but the problem I have is that speed (integrated 4Mhz) and memory to short to include all functions I need. In minimum size it works a little but often send wrong chars. Also it would be more interesting playing with strings chars.
So I bought a Pic18F4550 who have best RAM/ROM size and decided to add ext crystal (I have 4,8,16 and 20MHz)
Now, I just need ... to initialise my new pic, above all prepare serial in/out for non-lost chars.

If some of you can help me to do so I would be very happy

Thanks for reading and sorry for my bad english
 

Hello

You can find a clear explanation on how to use serial connection with a PIC18F4550 **broken link removed**. In this tutorial, they use the C18 compiler from microchip in the integrated programming environment MPLAB. On this site, you also find other tutorials that explain how to start from scratch and build your projects and programs. I find it very readable. The programming language is the standard language C.
 

Miredox

Thanks for your answer and have happy days
Unfortunately, I don't want to learn "c" language because I think it would be very long :cry:

I began to understand how to do with PIC48F4550 but I have now a problem concerning PORT settting.
To be more exact: I saw this PIC has many analogic inputs so, for the future, I thinked about having every battery cell (16 cells actually) value.
That's mean I need to use most of them except from RE port
On the picture you will see just one input connected to resistor for test.
RE port must be digital input only except RE2 who is an output (to control future multiplexer for cell values).

I know the code below is false for ADCON1 but i's just so you can tell me how to set every "AN" pins so some are digital and some other not.
Rem are in french, sorry ;-)

ADCON1 = %0000011100000
' CBA9876543210
' |||||||||||||
' ||||||||+++++--- AN0,AN1,AN2,AN3,AN4 en entrées analogiques
' |||||+++-------- AN5,AN6,AN7 en E/S classiques
' +++++----------- AN8,AN9,AN10,AN11,AN12 en entrées analogiques


ADCON0 = %00000001
'76543210
'||||||||
'|||||||+--- activation conversion analogique
'||||||+---- état de la conversion (0=attente/fin, 1=en cours)
'||++++----- choix du Canal d'entrée
'++--------- inutilisé

ADCON2 = %10111110 ''temps conversion=Fosc/2, temps acquisition=1TAD, alignement résultat=droite
'76543210
'||||||||
'|||||+++--- temps conversion (Fosc): 110 = 64
'||+++------ temps acquisition (Tad): 001 = 2 .
'|+--------- inutilisé
'+---------- Format résultat: aligné à droite



My software works except for E digital inputs

Thanks for reading and helping
 

Of course Re3 input works (because it's not analogic input, I just disable MCLR)
 

Hello Orphee

No problem, although I have to say that I programmed in both, but personally I prefer programming in C, as it is better structured, making my programs better readable and easier to debug (especially with the integrated realtime debugger in MPLAB). Also, the many libraries that exist for C can save you a lot of time.

For the analog inputs on the PIC18F4550, you have to enable them "in order", it is if you want to use 5 inputs, you have to use AN0 to AN4. If you want to use more inputs, you have to enable more inputs, starting from AN5 and further. So you can not use AN5 as digital input, and then AN6 as analog input.
However, you can use a trick if you want to use more analog inputs and not having all inputs in between as analog. Therefore, you have to dynamically change the number of analog inputs: when you want to start an analog to digital conversion, set all inputs in the range as analog, do the conversion, and afterwards set the number of analog channels back to a value smaller than 5. The limitation is that you will not be able to use the digital inputs of the RE-channel during an analog to digital conversion.
 

OK I (probably) understand so ... what about using AN 11,12 as digital inputs instead of AN5 and AN6 for digital output ? ;-) I would put AN10 for digital output too.

Can I do this ?


The problem I don't understand at all is how can I tell ADCON1 for this: it looks like if it has 13 bits and, for example, I can't write ADCON1 = %1111111111111, it just accepts 8 bits.

Stupid I am: I haven't seen I had RB5,RB6,RB7 not used !
 

Now a new problem: mikrobasic is not very very ... good for big soft !
Because it was telling me about no more place, I tried to see when problem occurs.
In fact, without anything in (empty software), it tells me about 71% RAM !
After, when programming, you must test one way or other one to decrease final size.
:cry:

So I have the choice: learning another langage or trying and trying with this.

Ok.
Perhaps this update could help someone in the future

With mikrobasic, don't write like this:
String1=string1+...

because, each time you use, you will lost 10% more for RAM !!!
I think it create space for intermediate value.

Problem too using x=StrToInt(string1)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top