PDA

View Full Version : how large and complex firmware you design using pbp?



chrdcv
- 5th December 2008, 18:07
I am actually involving in re-wrote some pieces of code for one AVL vehicle tracker developed with microchip pic18f6627 uC. In this design, Melabs PIC BASIC PRO was used for develop the entire source code (in BASIC dialect).

The project initiate in 2005 and now, need some modifications (because of use another GPS module, GSM modem, and others fews hardware modifications). The main problem now concern about the methodologies adopted for another two programmers that begin the design:
1. They donīt use interrupts in serial tx and rx, the data comming from modules (GPS and GSM) are treated by polling using serin/serout subrotines

2. Not develop a good programming practice, the unstructural aproach result in poor code design, large utilization of gotoīs statements instead of gosubīs.

3. Usage some peaces of assembly code for build data arrays instead of use arrays in BASIC language.

Well, thats is all. Then I would like hear if someone develop huge firmware using PIC BASIC PRO, the dificulties founded and the programmings abstractions utilized for contourn then.

Thanks in advance, chrdcv.

mackrackit
- 5th December 2008, 18:51
I have heard some say that PBP has a lot of blote, I do not know. I think is comes down to the one at the keyboard.

I have never had any troubles from using PBP no matter how big the program, so I can not speak of any difficulties.

BTW... No need to double post. That just uses up code space :)

chrdcv
- 5th December 2008, 23:14
Thanks mackrackit!

I would like hear some commentaries about vast usage of BASIC programming dialect in embedded world! Personally, I am re-writting all code in C or forth (programming languages that I dominate), but my boss insistis finishes it with BASIC.

About replicate topic, sorry :D I put firs message in wrong section then I put again in correct area! I would advice that the same error not will occur again!

Thanks again and have a nice weakend!
christian

Charles Linquis
- 5th December 2008, 23:35
I have a program that completely fills a 128K part (18F8723). It has about 8000 lines of source, and the .HEX file that I use to program the part is 342K bytes.

Bruce
- 5th December 2008, 23:59
I've been designing embedded products for over 15 years now. Started on the 8051, and
migrated to the PIC when a friend of mine introduced me to PBP.

I have never looked back to the 8051 series, and have never had a single problem with any
code that wasn't something "I" caused. PBP is hands-down the best BASIC compiler for the
PIC - period.

Write a tiny program - or one that completely fills the chip, and it's still rock soild.

I know it sucks to take over a project done by someone that may/may not have had a clue,
but if you're using PBP, then you have one of the best PIC compilers on the planet, and you
should have no problems cleaning up the mess you've been handed...;o}

I also do a lot of work in C, and assembler, but nothing beats PBP for quick & reliable results.

Acetronics2
- 6th December 2008, 10:47
Hi, CHRDCV

Reading your post Twice ...

I do not think you are facing a "tool" problem ... but "Method" problem ...

as Bruce says ... " nothing beats PBP for quick & reliable results " and I really do agree !!! On my amateur side, I build lots of programs ... but each program for few chips !!!

You won't find a better tool for developing applications quickly ...

IF you look for Bytes saving ... do not say PBP need Huge memory room nor ( cf your point 3 ) : PBP produced code for tables is very close to assembler !!! ... and the "structure" is very similar !!!

Most of time it is a "programming style" issue, as Basic permits dozens of ways to solve one "operation"
Some funny contests on this forum have shown code size factor could vary from 1 to .... 10 and even more !!!


Now ... the ONLY Basic language ( straight following the manual ... ) "weakness" i've found is for interrupts ... that often leads to carefully design the flow of the program.
But with some "unregistered" tricks ... It can be as quick as Assembler !!!

And remember "structuring" a program is not a must with Basic ... but it greatly helps to get a readable listing ... once more, it's not a Language but writer question.


In the End ...

What elders did is not always stupid ... they just thought another way of us ...

What about trying to understand their work a bit ???

Alain

Pedro Santos
- 6th December 2008, 12:42
Hello

It depends what you want doe. For many years i wrote all my programs in PBP Pro and all work fine. For a new project that i need use spi, sd card with FAt32, Color TFT, RTC and Temperatur i have change to Atmega2561 and BAscom and i can only say fantastic. I like PBP Pro but all that i need for the project the Bascom compiler support it and mutch more.
For little projects i use sometimes PBP Pro

Regards
Pedro

chrdcv
- 8th December 2008, 22:07
Thanks all for answers!

I think that like say Mr. Nygaard: "Programming is understanding", independent of the used languages. But even language have yours tricks and my intention here is know more about then in pic basic pro.

I describe the current work for give some ideas and find similars works made with the same language, in last metrics of the entire project, I discover that all project have 11675 lines (excluding commentaries and pre-processor directives). So to implement new methods, I will need know more about the greats techniques using pic basic pro and re-write some pieces of code. In firs view of actual code, Iīve found some unstructural programming method (large usage of gotoīs) and wast time in main loop using pause , serin2 and another polling methods. My first intention is re-write these methods in structural way, withou of use of gotoīs statements and communications serial polling for two hardware serials.

In essence, the product is one avl then I need some peaces of code giving support for "application" code.

Again, thanks a lot ...:D:D:D

rmteo
- 10th December 2008, 17:35
I have a program that completely fills a 128K part (18F8723). It has about 8000 lines of source, and the .HEX file that I use to program the part is 342K bytes.
Just out of curiosity, what does your application do that takes up 128K?

Charles Linquis
- 10th December 2008, 21:46
Monitors 9 fan tachometers, 5 analog voltages, 4 temperatures, 4 currents and up to 32 humidity sensors, displays all data on LCD and LEDs, drives about 10 parallel I/O and runs relays and controls fan speeds on the basis of temperature using the PWM controller, talks over RS-232 and Ethernet using UDP, tcp, SNMP and SSH protocols. The heavy network stuff is handled by a Lantronix XPORT or MatchPortAR, although all the SNMP and trap handling is done by the PIC.

Virtually everything is programmable through menus. All the display, entry and bounds checking routines take up quite a bit of codespace.

rmteo
- 10th December 2008, 21:53
Thank you, Charles.

chrdcv
- 11th December 2008, 17:27
Incredible Charles! congratulations for its work! Very nice!

How you structuralized the source code? You use state machine with interrupt for receive data from RS232? And the "parser" for decode each string from serial? You can post more details?

Thanks, christian

Charles Linquis
- 11th December 2008, 20:57
I can give you a few details.
The tachometers are read with an ASM interrupt on a 500uSec timer. Input ports are read and XORed against their last readings. If any bit has changed, a corresponding variable is incremented.
After 1 second (2000 interrupts), the variables are stored and the process repeats.

A main PBP loop reads the stored variables and calculates the fan RPMs. It also reads the A/Ds, calculates the required PWM values and writes that value directly to the hardware PWM registers, and writes to the LCD and LEDs. Another counter in the main timer interrupt routine paces everything.

Two PBP interrupts read the two USARTS and process input serial data and SNMP packets.

It does quite a few other things as well, but I have a conference call starting in a few minutes!

Charles Linquis
- 12th December 2008, 04:33
A few more details - the main PIC communicates with a network of current, humidity and pressure sensors. Each of the remote sensors is built with an 18F2321. Every two seconds the main PIC sends three bytes - the address, a command, and a checksum to all the slaves using DEBUGOUT (since all the USARTS are already used). The appropriate slave sends back 4 bytes - the address of the slave, two bytes of data, and a checksum. Open-collector mode is used so that the outputs of the sensors can all be tied together on one wire (an 820 ohm pull-up is used). The slaves all respond to address 254 by default on programming. Whatever number is sent in the command byte to a slave at address 254 becomes the slave's new address and is stored in the '2321's EEPROM. This way a slave's address can be set without using jumpers. The slaves all run on their internal 8Mhz oscillators, and amazingly, communicate reliably at 19.2K baud with the master (which is running at 40Mhz).
I did have to modify PBPPIC18.LIB to allow DEBUGOUT (on the slaves) to run open-collector.

The slaves basically read their associated sensor(s) and then sit in a tight loop waiting for the main PIC to send their address and command. As soon as they recognize their address, command and checksum, they wait 10uSec and send the data back.


This is probably more than anyone wanted to read, but you asked...

Ron Marcus
- 13th December 2008, 15:08
I started on PBP, and have designed hundreds of programs for commercial products. I was tempted to play with Swordfish for 32 bit variables, but since Melabs released 2.50, I have had no need. The most timing critical app was a video on screen display using a 16F628 and gated oscillator. This I did in assembly.
Being an RF junkie, I recently started programming the TI 1110 and 2510 RF transceivers. These are 8051 derivative cores, so C was the only way to go. It was a real challenge going from PBPs "anything goes" forgiving language to a fanatically rigid structure of program writing, but it helped my coding style.
I still haven't hit my head with PBPs capabilities, but I'll keep trying!
Ron

Archangel
- 13th December 2008, 17:18
This is probably more than anyone wanted to read, but you asked...Nope, sometimes the thought process behind the code is more valuable than a code example. Very interesting, Thanks Charles !
JS

chrdcv
- 21st December 2008, 20:08
Thanks Charles, Marcus and others!

Now I am really impression with your design and methods! One guy mention about swordfish compiler (http://www.sfcompiler.co.uk/swordfish/). I read more about the compiler and I like it. I dont know if it is so trustworthy how much melabs pic basic...:D:D:D

Well, I continue re-write and develop some code pieces in my spaghetti project and I will post in no longer future some doubts...

At the moment, Merry Christmas and Happy New Year!!!

rmteo
- 22nd December 2008, 00:30
I use SwordFish and I think that it is heads & shoulders above any other BASIC compiler for PIC's out there. But then again, that is MY opinion. :D :D :D

The only downside is that it supports PIC18s only. Now, if it has support for the PIC24 and dsPICs, I would be in hog heaven.