CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Need Help for HD44780 Programming with PIC16F876A
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Wed Jan 10, 2007 7:06 pm     Reply with quote

One thing I would like to ask regarding PSU....

There are transformers out there with ratings such as "XX" VA. I understand technically that VA = Watts of power generated. If I require a 12VDC and around 300mA of current, should the power rating then be 3.6VA Question
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jan 10, 2007 7:21 pm     Reply with quote

The ones that I use never have a "VA" rating on them. They just
specify the nominal unregulated DC voltage and the maximum current.
Here's a typical wall transformer from CUI. It's 12vdc unregulated,
at 500 ma, with the P5 plug. I have one of these.
http://www.digikey.com/scripts/dksearch/dksus.dll?KeywordSearch?MPart=DPD120050-P5P-SZ&site=us

Data sheet:
http://media.digikey.com/pdf/Data%20Sheets/CUI%20Inc%20All%20Brands%20PDFs/DPD120050-P5P-SZ.pdf

Data sheet for an alternate source:
http://www.mouser.com/catalog/specsheets/164139.pdf
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Jan 10, 2007 7:29 pm     Reply with quote

Quote:

There are transformers out there with ratings such as "XX" VA. I understand technically that VA = Watts of power generated. If I require a 12VDC and around 300mA of current, should the power rating then be 3.6VA


Technically VA and Watts are not the same, but in DC they have the same meaning and value.
Yes, a 12VDC @300mA power supply has a power rating of 3.6VA.


Humberto
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Thu Jan 11, 2007 7:13 am     Reply with quote

Tks for the info though i'm in UK. But i've found some wall transformers from some UK retailer. Am currently waiting for it to arrive.

Just to double-check. The datasheet for my voltage regulators is at "http://www.farnell.com/datasheets/1760.pdf". According to Page 2 of the datasheet, Vin must be 19V in order for Vo to be 12V. When i measure the input voltage of the IC340A, it registers ~19.2V but output regsiters just ~10.1V. Is this correct?Or can i safely say that the Vreg is damaged?


PCM programmer wrote:
The ones that I use never have a "VA" rating on them. They just
specify the nominal unregulated DC voltage and the maximum current.
Here's a typical wall transformer from CUI. It's 12vdc unregulated,
at 500 ma, with the P5 plug. I have one of these.
http://www.digikey.com/scripts/dksearch/dksus.dll?KeywordSearch?MPart=DPD120050-P5P-SZ&site=us

Data sheet:
http://media.digikey.com/pdf/Data%20Sheets/CUI%20Inc%20All%20Brands%20PDFs/DPD120050-P5P-SZ.pdf

Data sheet for an alternate source:
http://www.mouser.com/catalog/specsheets/164139.pdf
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Thu Jan 11, 2007 7:15 am     Reply with quote

Tks for answering my question.

Humberto wrote:
Quote:

There are transformers out there with ratings such as "XX" VA. I understand technically that VA = Watts of power generated. If I require a 12VDC and around 300mA of current, should the power rating then be 3.6VA


Technically VA and Watts are not the same, but in DC they have the same meaning and value.
Yes, a 12VDC @300mA power supply has a power rating of 3.6VA.


Humberto
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

Vcc power
PostPosted: Fri Jan 12, 2007 11:37 am     Reply with quote

Ok....I have just added a +12V regulated wall transformer to my ckt. Output from LM7805 is 5.00V. I have also inserted a 0.1uF ceramic decoupling capacitor to the Vcc input of PIC. But no luck with LED being lit.

B.t.w, when i've measured the voltage from each pin w.r.t (with respect to) Gnd, an AC voltage is measured. I also understand from books that by default, the TRISx registers of the PICs will be default to input state upon reset. So if I do not define PIN_B0 to be output by setting the TRISx registers, how will the LED on PIN_B0 light up?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 12, 2007 11:56 am     Reply with quote

If you use the code below, then the pin B0 is made an output automatically.
It is what we call standard IO.
It is part of the output_high, output_low, output_port,input_n commands.
If you instead use #fast_io then YOU are responsible for setting the tris value with the set_tris_n command.
Code:
#include <16F876A.H>
#fuses XT, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

//=========================
void main()
{

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}

Have you checked the clock? Also check that mclr has a pull-up on it.


Last edited by treitmey on Fri Jan 12, 2007 12:06 pm; edited 8 times in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jan 12, 2007 11:58 am     Reply with quote

Quote:

I have also inserted a 0.1uF ceramic decoupling capacitor to the Vcc input of PIC.
When I've measured the voltage from each pin with respect to Gnd,
an AC voltage is measured

The problem is that you're learning hardware at the same time that
you're learning CCS. You probably should have a bought a
development board. For example, with regard to the 0.1uF cap,
it's our intention that you connect it between the Vdd pin and the
ground pin. But it's possible that you mistakenly put it in series
with the +5v power, which would make the whole circuit not work.
Or, you may not even have a common ground connection from
the wall transformer to the regulator, to the PIC.
It's tough for us to get this information in a text-based forum.
In the past, some people have taken a CCD camera image of
their board and posted it on a free-posting website and provided
a link. You should either do that or buy a development board.
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Fri Jan 12, 2007 1:47 pm     Reply with quote

I did not include the #fast_io setting. I had tried to do it with & without tje set_tris_x() command. It seems that if I use the "set_tris_x()" command, the LED on PIN_B0 will light up on and off...Though the funny thing is if I simulate the on & off of the LED using the "while (1)" command, it doesn't run @all. If i just do it normally using output_high & output_low, the LED works perfectly fine. But if I use the "while (false)" command, it somehow only loops the commands in the "while()" brackets once and then it stops there (i.e. it dosen't loop at all). Will try to post pics for better illustration.

MCLR has a 1k pull-up resistor connected in series to Vcc line.

treitmey wrote:
If you use the code below, then the pin B0 is made an output automatically.
It is what we call standard IO.
It is part of the output_high, output_low, output_port,input_n commands.
If you instead use #fast_io then YOU are responsible for setting the tris value with the set_tris_n command.
Code:
#include <16F876A>
#fuses XT, NOWDT, NOPROTECT, NOBROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

//=========================
void main()
{

while(1)
  {
   output_high(PIN_B0);
   delay_ms(500);
   output_low(PIN_B0);
   delay_ms(500);
  }

}

Have you checked the clock? Also check that mclr has a pull-up on it.


Last edited by kevin5k on Fri Jan 12, 2007 1:54 pm; edited 1 time in total
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Fri Jan 12, 2007 1:51 pm     Reply with quote

I'll try and upload pics. Problem is, my Uni isn't willing to fork out the $$$ for the CCS C Compiler. I had to dig into my own savings to do so...Erm, the 0.1uF cap I put it in parallel. But tks for pointing out my possible error anyway.

Good news though...I had received the PIC Dem2 Plus Devlopment board. Will start experimenting my PIC using that board instead.

PCM programmer wrote:

The problem is that you're learning hardware at the same time that
you're learning CCS. You probably should have a bought a
development board. For example, with regard to the 0.1uF cap,
it's our intention that you connect it between the Vdd pin and the
ground pin. But it's possible that you mistakenly put it in series
with the +5v power, which would make the whole circuit not work.
Or, you may not even have a common ground connection from
the wall transformer to the regulator, to the PIC.
It's tough for us to get this information in a text-based forum.
In the past, some people have taken a CCD camera image of
their board and posted it on a free-posting website and provided
a link. You should either do that or buy a development board.
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

How to clear LCD?
PostPosted: Mon Jan 15, 2007 9:51 pm     Reply with quote

what command do I use to clear the LCD display say upon processor reset in main program? I am only aware of the following commands useful in flex_lcd.c file

========================================
int8 const LCD_INIT_STRING[4] =
{
0x20 | (lcd_type << 2), // Func set: 4-bit, 2 lines, 5x8 dots
0xc, // Display on
1, // Clear display
6 // Increment cursor
};

void lcd_init(void)
{
int8 i;

output_low(LCD_RS);

#ifdef USE_LCD_RW
output_low(LCD_RW);
#endif

output_low(LCD_E);

delay_ms(15);

for(i=0 ;i < 3; i++)
{
lcd_send_nibble(0x03);
delay_ms(5);
}

lcd_send_nibble(0x02);

for(i=0; i < sizeof(LCD_INIT_STRING); i++)
{
lcd_send_byte(0, LCD_INIT_STRING[i]);
#ifndef USE_LCD_RW
delay_ms(5);
#endif
}

}
========================================

Anyone....Please advise...Tks...
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Tue Jan 16, 2007 1:43 am     Reply with quote

In FlexLCD.c I have the following defines:

Code:


// Display ON/OFF Control defines
#define DON       0b00001111        // Display on
#define DOFF      0b00001011        // Display off
#define CURSOR_ON 0b00001111        // Cursor on
#define CURSOR_OFF   0b00001101        // Cursor off
#define BLINK_ON  0b00001111        // Cursor Blink
#define BLINK_OFF 0b00001110        // Cursor No Blink


#define CLEAR_DISPLAY      0b00000001  // addition
#define CURSOR_HOME        0b00000010  // Get rid of any scrolling effects


// Cursor or Display Shift defines
#define SHIFT_CUR_LEFT     0b00010011  // Cursor shifts to the left
#define SHIFT_CUR_RIGHT    0b00010111  // Cursor shifts to the right
#define SHIFT_DISP_LEFT    0b00011011  // Display shifts to the left
#define SHIFT_DISP_RIGHT   0b00011111  // Display shifts to the right

// Function Set defines
#define FOUR_BIT  0b00101111        // 4-bit Interface
#define EIGHT_BIT 0b00111111        // 8-bit Interface
#define LINE_5X7  0b00110011        // 5x7 characters, single line
#define LINE_5X10 0b00110111        // 5x10 characters
#define LINES_5X7 0b00111111        // 5x7 characters, multiple line


Then you can use

Code:

/////////////////////////////////////////////////////////////////////////
/// Completely clear the contents of the display
/////////////////////////////////////////////////////////////////////////

void ClearDisplay (void)
{
   lcd_send_byte (0, 0x80);     // Set memory to first line
   lcd_send_byte (0, CLEAR_DISPLAY);
   lcd_send_byte (0, 0xc0);     // 'Second' line
   lcd_send_byte (0, CLEAR_DISPLAY);

}
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Tue Jan 16, 2007 3:37 am     Reply with quote

I suppose I could omit this section of your codes

davekelly wrote:
In FlexLCD.c I have the following defines:

Code:


// Display ON/OFF Control defines
#define DON       0b00001111        // Display on
#define DOFF      0b00001011        // Display off
#define CURSOR_ON 0b00001111        // Cursor on
#define CURSOR_OFF   0b00001101        // Cursor off
#define BLINK_ON  0b00001111        // Cursor Blink
#define BLINK_OFF 0b00001110        // Cursor No Blink


#define CLEAR_DISPLAY      0b00000001  // addition
#define CURSOR_HOME        0b00000010  // Get rid of any scrolling effects


// Cursor or Display Shift defines
#define SHIFT_CUR_LEFT     0b00010011  // Cursor shifts to the left
#define SHIFT_CUR_RIGHT    0b00010111  // Cursor shifts to the right
#define SHIFT_DISP_LEFT    0b00011011  // Display shifts to the left
#define SHIFT_DISP_RIGHT   0b00011111  // Display shifts to the right

// Function Set defines
#define FOUR_BIT  0b00101111        // 4-bit Interface
#define EIGHT_BIT 0b00111111        // 8-bit Interface
#define LINE_5X7  0b00110011        // 5x7 characters, single line
#define LINE_5X10 0b00110111        // 5x10 characters
#define LINES_5X7 0b00111111        // 5x7 characters, multiple line


and I could use this section of your code.....Just curious though...why do U define the bits as "0b00xxxxxx"?Y not use hexadecimal?

davekelly wrote:

Code:

/////////////////////////////////////////////////////////////////////////
/// Completely clear the contents of the display
/////////////////////////////////////////////////////////////////////////

void ClearDisplay (void)
{
   lcd_send_byte (0, 0x80);     // Set memory to first line
   lcd_send_byte (0, CLEAR_DISPLAY);
   lcd_send_byte (0, 0xc0);     // 'Second' line
   lcd_send_byte (0, CLEAR_DISPLAY);

}
davekelly



Joined: 04 Oct 2006
Posts: 53
Location: Berkshire, England

View user's profile Send private message

PostPosted: Tue Jan 16, 2007 3:45 am     Reply with quote

The only reason I posted the define section, is I had used the CLEAR_DISPLAY in the function, which makes it more readable then sending a 1.

The rest of the defines may be useful when performing more advanced functions.

The 0b00xxxxxx codes were from a previous LCD driver I wrote for another compiler written from scratch using the spec sheet for the display. Most of the functions have a specific code, then a single bit changes the function to on or off. This is more obvious when looking at the binary pattern than the hex pattern. It makes no difference functionally, just the way I implemented it years ago.
kevin5k



Joined: 08 Jan 2007
Posts: 41

View user's profile Send private message

PostPosted: Tue Jan 16, 2007 11:03 am     Reply with quote

No offence davekelly.....I'm just a newbie. Just like to ask this and that....Many thanks....

davekelly wrote:


The 0b00xxxxxx codes were from a previous LCD driver I wrote for another compiler written from scratch using the spec sheet for the display. Most of the functions have a specific code, then a single bit changes the function to on or off. This is more obvious when looking at the binary pattern than the hex pattern. It makes no difference functionally, just the way I implemented it years ago.


Another question though.....My PCB transformer has 2 secondary outputs. So if the PCB transformer has a 5VA rating (2.5VA per secondary winding) does that mean that if my circuit requires only either (+/-)12VDC each secondary coil will produce ~208mA of current? Sorry if i'm asking stupid questions.... Embarassed
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group