mityeltu

EstablishedMember

95

Posts posted by mityeltu

1. Float Format For Lcd

OK, excellent... It DID work that way, but I still have not figured out how this exponent thing will work. Since I know where the exponent lies within the float, do I need to extract it from the float so I know where the decimal point is supposed to be in the number?

For instance, if I multiply 100 * 100 I should get 10000, and in the float format, I would assume I would have an exponent of +4. I'm not sure I really sure the format is correct though. According to what I know of math, the mantissa is actualy the fractional part of the number, in which case I would be missing the integer part. Did I miss sonething there?

2. Float Format For Lcd

Ok, so you're saying I can handle the floats like any other numerical animal I come across? I'll try it, but it doesn't make sense. If the float is composed of 3 parts and I multiply the entire thing by some factor (say 1000) have I not just changed all the values, or is sourceboost smart enough to handle this manipulation for me?

3. Float Format For Lcd

I am working on a simple (I call it that) project to display the results of the pythagorean theorem. I have the user input 'a' and 'b' and then I want to display 'c'. The problem is getting 'c'. I know the format is |signbit(1)|exp(8)|mantissa(23)| So, my real question is, how can I format this for display on an LCD?

I tried the following, just to see if I could use a brute force method on it. The output is as follows: 11001111001 and another 21 zeros. I know this is in reverse order because of the way I'm ripping out the bits, but it doesn't make any sense to me either way. Does anyone have any suggestions?

I'm using the 16f887 for this project.

```#include <system.h>
#include <lcd_driver.h>
#include <float.h>

#define LCD_ARGS  2, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \
1,	 /* Use busy signal: 1 = use busy, 0 = use time delays */\
PORTB, TRISB,  /* Data port and data port tris register */ \
PORTB, TRISB,  /* Control port and control port tris register */ \
1,	/* Bit number of control port is connected to RS */ \
2,	/* Bit number of control port is connected to RW */ \
3	 /* Bit number of control port is connected to Enable */

float a, b, c, a_sqr, b_sqr, c_sqr;
char i, out, x, y;

void main()
{
intcon = 0;
ansel = 0;
anselh = 0;

trisa = 0;
trisb = 0;
porta = 0;
portb = 0;

lcd_setup();
//a^2+b^2=c^2
a = 1.0;
b = 1.0;
x = 2;
y = 0;
lprintf("c=");
while (1)
{
a_sqr = float32_mul(a, a);
b_sqr = float32_mul(b, b);
c = float32_sqrt(c_sqr);
//floats are 32 bits
for (i = 0; i <= 31; i++)
{
if (test_bit(c,i))
{
out = 0x31;
}
else
{
out = 0x30;
}
lcd_gotoxy(x,y);
lcd_datamode();
lcd_write(out);
x++;
if (x == 18)
{
x = 0;
y = 1;
}
}
while (1)
{}
}

}```

4. Sourceboost Development Board

Is there a development board available commercially that is ready to accept sourceboost hex files? i ask because I have been using the EasyPic6 from mikroelectronika and it really sucks (the mikrobasic, not the devolpment board -- too buggy). It will NOT take code generated from sourceboost without extensive modifications for such simple peripherals as LCD, 7-seg, etc. I frankly don't have the patience to keep rewriting the header files etc.

So, is there a development board out there specifically designed for sourceboost?

5. Float & Lcd

Ok, I saw one problem.... (BIG problem really) I was subtracting rather than adding.... That's fixed, but I would still rather have an EASY way to display this value rather than the brute force method I'm about to undertake.

6. Float & Lcd

I am working on a simple (I call it that) project to display the results of the pythagorean theorem. I have the user input 'a' and 'b' and then I want to display 'c'. The problem is getting 'c'. I know the format is |signbit(1)|exp(8)|mantissa(23)| So, my real question is, how can I format this for display on an LCD?

I tried the following, just to see if I could use a brute force method on it, but all I got were zero's. Does anyone have any suggestions?

I'm trying to use the 16f887 for this project.

```#include <system.h>
#include <lcd_driver.h>
#include <float.h>

#define LCD_ARGS  2, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \
1,	 /* Use busy signal: 1 = use busy, 0 = use time delays */\
PORTB, TRISB,  /* Data port and data port tris register */ \
PORTB, TRISB,  /* Control port and control port tris register */ \
1,	/* Bit number of control port is connected to RS */ \
2,	/* Bit number of control port is connected to RW */ \
3	 /* Bit number of control port is connected to Enable */

float a, b, c, a_sqr, b_sqr, c_sqr;
char i, out, x, y;

void main()
{
intcon = 0;
ansel = 0;
anselh = 0;

trisa = 0;
trisb = 0;
porta = 0;
portb = 0;

lcd_setup();
//a^2+b^2=c^2
a = 1.0;
b = 1.0;
x = 2;
y = 0;
lprintf("c=");
while (1)
{
a_sqr = float32_mul(a, a);
b_sqr = float32_mul(b, b);
c_sqr = float32_sub(a_sqr, b_sqr);
c = float32_sqrt(c_sqr);
//floats are 32 bits
for (i = 0; i < 31; i++)
{
if (test_bit(c,i))
{
out = 0x31;
}
else
{
out = 0x30;
}
lcd_gotoxy(x,y);
lcd_datamode();
lcd_write(out);
x++;
if (x == 16)
{
x = 0;
y = 1;
}
}
while (1)
{}
}

}```

7. Simple Usb... I Need Help

Ian,

That sounds great, yes. I would love to be able tp generate the Sourceboost C code. I could easily (I think) port it over to mikrobasic (I hate this platform, but it's what my boss wants me to use). All I really need is the USBdsc file.... This is really way over my head... I'm a power engineer, not controls or programmer. I have to wera alot of hats around here.

Tell me what you need me to do.

Thanks.

8. Simple Usb... I Need Help

I'm not new to pic programming, but I *am* new to USB programming. I have looked all over the place for a simple usb interface that will allow me to communicate with the pc using pic18f4553. I have found some snippets of code, but they won't compile or won't run.

I have no real understanding of how to make this thing work with a PIC. Is there anyone eho has a very simple listing that will compile and run? I can't even get the computer to realize that a device has been connected.

Just so you know, I have sourceboostC, but I am currently working with mikrobasic. I am certain I can port it over, but so far I have no idea what I'm doing. USB is very confusing to me. Can somone please help me?

9. Eeprom Routines

You are calling the read function just after you called the write function.

Writing to EEPROM takes time (several ms) so you have to wait for the write cycle to complete first. You can do this by waiting a fixed delay (say 10ms), poll for write complete (while (eecon1.WR) {}) or use interrupts to tell you.

Performing the read immediately after the write will probably abort the write operation.

I inserted a 255ms delay and it still did not write to the eeprom. For whatever reason this function does not work properly. If I gi to using the routine in the data sheet:

```eeadr = 0;
eedata = 9;
set_bit(eecon1,2);
eecon2=0x55;
eecon2=0xaa;
set_bit(eecon1,1);
clear_bit(eecon1,2);//this works -- takes 1ms to write, process continues
while (test_bit(eecon1,1))
{}//wait till finished -- this can be omitted for ongoing processes```

everything works fine, but the eeprom_write function does not work corredctly. If you have any other suggestions I am certainly willing to try them. I would rather use what resources I have rather than having to reinvent the wheel -- although, since the c version of the asm stuff from the datasheet works, I may as well just use that, but it still bothers me.... It SHOULD work, and it'll bug me till I figure out WHY it's not working.

10. Eeprom Routines

Has anyone had any issues with the SB Builtin EEPROM routines?

I hope sombody can enlighten me on this. I am working on a project for my boss and I'm running out of time. I have been trying unsuccesffully to write to my eeprom. The read routine works fine, but not the write. I am using the PIC16f887 with 8MHz internal oscillator. My oversimplified code is as follows:

```#include <system.h>
#include <eeprom.h>
#include <lcd_driver.h>

#define LCD_ARGS  2, /* Interface type: mode 0 = 8bit, 1 = 4bit(low nibble), 2 = 4bit(upper nibble) */ \
1,	 /* Use busy signal: 1 = use busy, 0 = use time delays */\
PORTB, TRISB,  /* Data port and data port tris register */ \
PORTB, TRISB,  /* Control port and control port tris register */ \
1,	/* Bit number of control port is connected to RS */ \
2,	/* Bit number of control port is connected to RW */ \
3	 /* Bit number of control port is connected to Enable */

void mcu_setup(void);

void main()
{
mcu_setup();

//writing does not work
dat = 0x01;

lprintf("m:");
one = one + 48;
lcd_write(one);
while(1)
{}
}

void mcu_setup()/**********************************MCU_SETUP***********************************/
{
intcon = 0x00;
ansel = 0;
anselh = 0;

trisa = 0xff;//porta inputs
trisb = 0x00;//portb outputs - lcd data
set_bit(trisb,0);//input for int0 -- not used
trisc = 0x00;//portc output
portc = 0;
trisd = 0x00;//portd output
portd = 0;
trise = 0xff;//porte input

lcd_setup();
}////////////////////////////////////////////////END MCU_SETUP////////////////////////////////////```

The reference manuals (help) are not ideal and a sentence or so on creating projects with several files and the use of libraries would be helpful to newbies. There are a few references to this on the forum and also a mention about c and lib files in the Tip Of The Day.

Basically any library function used must have it's .lib file added to the project. The only exception to this is the libc file which SourceBoost IDE adds automatically when linking. If you use MPLAB instead of the SB IDE then the appropriate libc must be added to the project as well.

Despite the poor references and a few compiler quirks and ommisions I think you will find the overall package effective and very good value.

Good luck with the rest of your project.

Regards

davidb

Fair enough. But I don't have to include anythig but the lcd_driver.h file for that to work. I understand from reading the file that the functions have been both declared and defined within a single file, but that sort of inconsistency is not going to make it simpler. Not complaining at you, just complaining. Thank you for the help and the insight.

Sincerely,

Tim

Regards

davidb

That was it..... Thank you. Why is that not mentioned in the help file? I mean, it states that the function is declared in the .h and defined in the .lib, but there is no statement to the fact that this file has to be added to the project. Am I just supposed to know that?

Thanks again.... when I get back home, I'll test it out, but at least it compiles now.

I'm stumped. I have been banging away at this project for more than 6 hours trying to get the sourceboost commands to work. They won't even compile. All I want ton do is read the ad result into a variable and then display it on an lcd. The lcd works fine. Here is the stripped down adc only code that won't copmpile. I compared it to what is done in the adc example, and everything is done the same, just not the same way... I am using the 16F887 with 8MHz internal oscillator. Can anyone please helkp me?

I get this error when compiling:

I tried declaring vartious combinations of variables locally and globally, but I frankly don't understand what thjat error even means.

```#include <system.h>

//unsigned char ch;

void main()
{
//unsigned char ch
char one, two, three;

unsigned char t = 500;
osccon = 0x71;

intcon = 0x00;
ansel = 0xe0;//channels 5,6,7 porte 0,1,2
anselh = 0x00;

trisa = 0x00;
porta = 0x00;
trisb = 0x00;
portb = 0x00;
trise = 0xff;

while(1)
{
delay_ms(t);
three = (ad_res % 10) + 48;
two = (ad_res % 10) + 48;
}

}```

14. Spi Interface & Boostc++

I have been looking into using an spi interface to a number of different modules as well as master/slave arrangements for my pics. I use sourceboost for most of my pic programming, but have used mikrobasic also in the past.

Is there not a set of SPI commands included with the sourceboost compilers? I would have imagined that this would be something the authors would want to include as it is a ncie easy way to communicate with a large number of peripheral devices.

on a different note, although maybe the same one, what is this one-wire communications set I see? Can anyone explain this?

Thanks.

15. Lcd_driver.h Editing

I have sine also tried to simply edit the existing header file and it then fails to find it using the same name and just modifying the existing text?
What fails exactlty?

Did you rename the existing file or rename it?

The error reads that it was unable to locate the file and then halts compiling.

I'll try reinstalling and see if that helps at all.

I doubt anyone is still following this thread, but it turns out that uninstalling and reinstalling the software fixed the issue. Thanks for the help.

16. Demo Board Lcd Problem

I am using boostc++ and writing a program for work. My boss bought a demo board from mikroelectronica that has the lcd wired funny: portb is used for data and control in what appears to be 4-bit low. The RW pin on the LCD is connected to ground. E=B5, RS=B4, Data=B0-B3 to lcd data pins D4-D7.

I am trying to rewrite the lcd_header.h file to be compatible with this configuration. I have tried to modify it but so far I get exactly zip on the lcd. I am certain the lcd is functional. I am certain my code is fucntional. These have both been tested in other ways. Can anyone help me out with this?

Where in the header file are the data pins set? I removed the rw pin from the template and from each of the defines (not sure if that helped or hurt). I don't really know what I'm doing on this, so any and all help will be greatly appreciated.

Tahnks.

17. Lcd_driver.h Editing

I have sine also tried to simply edit the existing header file and it then fails to find it using the same name and just modifying the existing text?
What fails exactlty?

Did you rename the existing file or rename it?

The error reads that it was unable to locate the file and then halts compiling.

I'll try reinstalling and see if that helps at all.

18. Lcd_driver.h Editing

Dave -> I have checked and the path to the linker is the sourceboost directory. Should this be changed to reflect the \include directory or does it understand to look within the folders IN the sourceboost directory? I can't imagine that it should as it has no problem locating the other header files.

I have sine also tried to simply edit the existing header file and it then fails to find it using the same name and just modifying the existing text?

I edited this with notepad to avoid any formatiing issues. Should I edit this file with something other than that?

19. Lcd_driver.h Editing

I agree, but nevertheless, the edited header file is located in the exact same dir4ectory (...\include) as the original file. When I #include<lcd_driver.h>, I get no problems; however, when I #include <lcd_driver2.h> it can't find the file. I have also, as previously mentioned, tried to add the file to the project, but that also did not help.

Is there anything anyone can suggest that might help me? I need to edit this file to work properly with the weird demo board my boss bought for me to use to prototype my projects.

20. Lcd_driver.h Editing

I work for a manufacturing company as an electrical controls engineer. I have been using PICs frequently in many of my home projects, but ony recently (last week) started using them also at work. My manager purchased the EasyPIC6 from MikroElectronica along with the MikroBasic compiler. Sad, I know.

I am supposed to use this to simulate my most recent program. This is not the problem, but the terrible limitations of the mikrobasic compiler are. I want to rewrite my program in BoostC and use the EasyPIC6 to simulate. Long story short.

Now the problem. The board is set for 4 bit low on the LCD and there is no r/w pin. I have tried to edit the BoostC LCD_driver.h header file to allow for only the passage of the "E" and "RS" inputs, but when I try to complie it says it can't locate the new header file. I even added it to my project and still nothing. Can anyone tell me either how to edit this header file so that I can include it in my program or how to write the code so that it will work with this odd board?

I hope someone out there can help me.

Thank you,

Tim: Chattanooga, TN

×
×
• Create New...