Showing posts with label Microcontroller. Show all posts
Showing posts with label Microcontroller. Show all posts

CAN BUS Interface With Microcontroller by SPI Circuit

CAN BUS Interface With Microcontroller by SPI Circuit



SYSTEM IMPLEMENTATION



MCP2515
Description
Microchip Technology’s MCP2515 is a stand-alone
Controller Area Network (CAN) controller that implements
the CAN specification, version 2.0B. It is capable
of transmitting and receiving both standard and
extended data and remote frames. The MCP2515 has
two acceptance masks and six acceptance filters that
are used to filter out unwanted messages, thereby
reducing the host MCUs overhead. The MCP2515
interfaces with microcontrollers (MCUs) via an industry
standard Serial Peripheral Interface (SPI).

Features
• Implements CAN V2.0B at 1 Mb/s:
- 0 – 8 byte length in the data field
- Standard and extended data and remote
frames
• Receive buffers, masks and filters:
- Two receive buffers with prioritized message
storage
- Six 29-bit filters
- Two 29-bit masks
• Data byte filtering on the first two data bytes
(applies to standard data frames)
• Three transmit buffers with prioritizaton and abort
features
• High-speed SPI™ Interface (10 MHz):
- SPI modes 0,0 and 1,1
• One-shot mode ensures message transmission is
attempted only one time
• Clock out pin with programmable prescaler:
- Can be used as a clock source for other
device(s)
• Start-of-Frame (SOF) signal is available for
monitoring the SOF signal:
- Can be used for time-slot-based protocols
and/or bus diagnostics to detect early bus
degredation
• Interrupt output pin with selectable enables
• Buffer Full output pins configurable as:
- Interrupt output for each receive buffer
- General purpose output
• Request-to-Send (RTS) input pins individually
configurable as:
- Control pins to request transmission for each
transmit buffer
- General purpose inputs
• Low-power CMOS technology:
- Operates from 2.7V – 5.5V
- 5 mA active current (typical)
- 1 µA standby current (typical) (Sleep mode)
• Temperature ranges supported:
- Industrial (I): -40°C to +85°C
- Extended (E): -40°C to +125°C

http://ww1.microchip.com/downloads/en/DeviceDoc/21801d.pdf

IAR Systems provides complete starter kit for high performance STM32 F-2 series of microcontrollers

IAR Systems today announced a complete starter kit for STMicroelectronics’ ARM Cortex-M3 based high performance STM32 F-2 series. The new leading-edge STM32F2xx series combines advanced 90nm process technology with the innovative adaptive real-time memory accelerator (ART accelerator) and the multi-layer bus matrix. IAR KickStart Kit for STM32F207 contains all the necessary hardware and software and allows embedded software applications to be designed, integrated and tested on hardware. It includes a feature-rich evaluation board, software tools, a debug probe, example projects and board support packages for several RTOSes. It is easy to use for evaluation and prototyping purposes thanks to a high level of integration between hardware, software and tools.

IAR KickStart Kit for STM32F207

The evaluation board is fitted with an STM32F207ZG microcontroller, color LCD, connectors for USB host, USB OTG, Ethernet and CAN, headphone jack, and many other peripherals. Debug connectors for ETM trace, SWD and JTAG are also included.

The included IAR J-Link Lite debug probe provides JTAG and SWD debug interfaces. Added debug capabilities can be enabled by separate debug probes. IAR J-Trace enables full instruction trace, and IAR J-Link Ultra enables power debugging features in IAR Embedded Workbench. Both probes are sold separately.

The kit is prepared for use with IAR Embedded Workbench, the most widely used tool chain for ARM based microcontrollers recognized for its efficient code generation, comprehensive debugger, and user friendly IDE.

IAR KickStart Kit for STM32F207 is in stock and available in IAR Systems’ e-shop. It is priced at EUR 209/USD 289. Part number is KSK-STM32F207ZG-JL.

iar.com

IAR Systems releases complete starter kit for NXP's LPC1780 microcontroller series

IAR Systems announced a complete starter kit for NXP’s ARM Cortex-M3 based LPC1780 microcontroller family. IAR KickStart Kit for LPC1788 includes a feature-rich evaluation board, software development tools, an IAR J-Link Lite debug probe, and software. A high level of integration between hardware, software and tools in combination with pre-configured example projects and board support packages from various RTOS vendors makes it very easy to use the kit and get started with evaluation and development.

IAR Systems releases complete starter kit for NXP's LPC1780 microcontroller series

The evaluation board is fitted with an LPC1788 microcontroller, a 3,5’’ color TFT touch screen, connectors for USB host, USB OTG, Ethernet and CAN, audio in and out, and many other peripherals. Debug connectors for ETM trace, SWD and JTAG are also included.

Features

  • Microcontroller
    • LPC1788FBD208 LQFP
  • User interfaces
    • 2x user buttons
    • LCD 3.5’’ 320x200 24bit color TFT with backlight and touch screen
  • Debug interfaces
    • JTAG/SWD connector - 20 pin 0.1’’
    • SWD connector - small 9 pin 0.05’’
    • ETMv3 connector - small 19 pin 0.05’’
  • Communication interfaces
    • RS232/ICSP
    • USB host and OTG
    • CAN driver and connector
    • IrDA
    • 100 Mbit Ethernet 12C routed to connector
    • UXT connector
    • EXT connector
    • QEI connector
  • Power functions
    • Multiple power supply options:
    • J-Link (pin 19)
    • Trace connector (pin 11&13)
    • External supply
    • Power supply LED
  • Additional features
    • Audio in and out
    • SD/MMC card connector
    • Trimpot
    • Accelerometer

The included IAR J-Link Lite debug probe provides JTAG and SWD debug interfaces. Added debug capabilities can be enabled by separate debug probes. IAR J-Trace enables full instruction trace, and IAR J-Link Ultra enables power debugging features in IAR Embedded Workbench. Both probes are sold separately.

IAR KickStart Kit for LPC1788 is prepared for use with IAR Embedded Workbench, the most widely used tool chain for ARM based microcontrollers recognized for its efficient code generation, comprehensive debugger, and user friendly IDE.

IAR KickStart Kit for LPC1788 is in stock and available in IAR Systems’ e-shop. It is priced at EUR 279/USD 399. Part number is KSK-LPC1788-JL.

AVR ATtiny10 is highly suitable for large volume market applications provide Six-pin Microcontroller

The latest AVR ATtiny10 is highly suitable for large volume market applications.

AVR ATtiny10 has 1kilobytes of programmable flash memory, 32 bytes of internal Static Ram, 8-bit Analog to Digital converter, a 16-bit timer with Pulse Width Modulation, 12 MIPS of processing throughput and an analog comparator.Using the AVR CPU, this device is supposed to give 6 times performance of any other similar size & cost device available in the market.

Atmel says “If your application needs higher processing power with lower current consumption, AVR ATtiny10 is the right soultion”

All tinyAVR microcontrollers use the standard AVR microcontroller development tools. The AVR Studio AVR integrated development environment is available free of charge on Atmel’s website. Samples of this microC is now available at a very small price of $0.35 for 10k units.


How AVR ATtiny10 ensures low power consumption?

This device with high processing efficiency reduces the time in active mode and more time will be spent in power saving sleep modes. In addition to this, Atmels picopower technology is used in this device which ensures low power consumption.

Key Parameters:

Flash (Kbytes) – 1
SRAM (Bytes) - 32
Max I/O Pins – 4
F.max (MHz) – 12
Vcc (V) – 1.8-5-5V
Analog Comparator – Yes

S:circuitstoday.com


New,PlayPIC to Learn PIC16F84A Microcontroller

This is a “PlayPIC to Learn PIC16F84A Microcontroller” new design of a tutorial board based on the popular PIC16F84A microcontroller. It features eight single leds, a 7-segment display, an LCD display and five push buttons. It is an ideal solution for the beginner to take his/her first programming steps in the world of microcontrollers. Having an in-circuit-programming (ICP) header, it can be easily reprogrammed without unplugging the microcontroller each time, provided that the programmer also supports this feature (like OziPic’er).

New,PlayPIC to Learn PIC16F84A Microcontroller

PIC16F84A Feature
RA0 JP2 – S3 – JP4
RA1 JP2 – S4 – JP4
RA2 JP2 – S5 – JP4
RA3 JP2 – S6 – JP4
RA4 JP2 – JP4

PIC16F84A Feature
RB0 JP2 – LED1 – 7 Seg (dp) – S7 Debounce – Buzzer
RB1 JP2 – LED2- 7 Seg (a) – LCD RS
RB2 JP2 – LED3- 7 Seg (b) – LCD R/W
RB3 JP2 – LED4- 7 Seg (c) – LCD E
RB4 JP2 – LED5- 7 Seg (d) – LCD DB4
RB5 JP2 – LED6- 7 Seg (e) – LCD DB5
RB6 JP2 – LED7- 7 Seg (f) – LCD DB6
RB7 JP2 – LED8- 7 Seg (g) – LCD DB7

Feature Description

  • S1 switches the board on and off. When on, the indicator led LED9 is lit.
  • S2 resets the microcontroller.
  • S8 switches the LCD display on and off
  • S9 switches the eight individual leds AND the 7-segment display on and off.
  • Push buttons S3 to S6 correspond to RA0-RA3 inputs. They are enabled or disabled by the SW2 dip switch.
  • The SW1 dip switch enables or disables the following features :
    • Connects RB0 (used as output) to LED1.
    • Connects RB0 (used as interrupt input) to S7.
    • Enables the debouncing circuit for interrupt switch S7.
    • Connects RB0 (used as output) to the buzzer.

This dip switch must be either 1000 or 0100 or 0110 or 0001.

  • The 7-segment display is always connected to the individual leds. Its seven segments correspond to LED2 to LED8 (RB1 to RB7) and the decimal dot to LED1 (RB0). This correspondence enables the 7-segment display to work together with the interrupt switch S7, which is connected to RB0.

Using V/F Techniques with COP8 Microcontrollers for 2-Way Multiplexed LCD Drive and Low Cost A/D Converter

2-Way Multiplexed LCD Drive and Low Cost A/D Converter Using V/F Techniques with COP8 Microcontrollers

Using V/F Techniques with COP8 Microcontrollers for 2-Way Multiplexed LCD Drive and Low Cost A/D Converter

This application note is intended to show a general solution for implementing a low cost A/D and a 2-way multiplexed LCD drive using National Semiconductor‘s COP840C 8-bit microcontroller. The implementation is demonstrated by means of a digital personal scale. Details and function of the weight sensor itself are not covered in this note. Also the algorithms used to calculate the weight from the measured frequency are not included, as they are too specific and depend on the kind of sensor used.

Typical Applications

  • Weighing scales
  • Sensors with voltage output
  • Capacitive or resistive sensors
  • All kinds of measuring equipment
  • Automotive test and control systems

Features

2-way multiplexed LCD drive capability up to 30 segments (4 digit and 2 dot points)
  • Precision frequency measurement
  • Low current consumption
  • Current saving HALT mode
  • Additional computing power for application specific tasks

S:electronicsuite.com

ATMEL 89C4051 CMOS MicroController based digi thermo (cute palm sized)

This is Digi Thermo Cute Palm-Sized using ATMEL 89C4051 CMOS MicroController, is a device specially designed for measuring and time and temperature in chemistry laboratory.

  • The MCU: ATMEL 89C4051 CMOS Microcontroller with 4kB code memory, 128 bytes On-chip RAM and 8-bit Port1 and Port3.
  • The A/D chip: HARRIS CA3162, 3-digit DVM.
  • The A/D converter employs dual-slope integrator providing 10Hz sampling rate, while Digital output sent to MCU will be multiplexing four bit BCD started from MSD, LSD and NSD respectively.
  • Integrating capacitor: 330nF Polyester.
  • The 10k POT that connected to Pin 13 is a gain adjustment, while 50k POT to pin 8 and 9 is for zero adjustment purpose.
  • Pin 11 for HI and Pin 10 for LO for differential the input of converter.
  • LM35D used for temperature measurement tool.
  • The output signal is 10mV/°C.
  • First order low-pass filter acts as front-end hardware filtering is forming by a 100k and 0.02uF.
  • The 16×1 line LCD is connects in 4-bit interfacing to P1.4-P1.7.

The +5V power supply uses a 78L05 TO92 case with an external +9V adapter.

ATMEL 89C4051 CMOS MicroController based digi thermo (cute palm sized)

S:electronicsuite.com

AT 90S2313 microcontroller based AVR digital counter with Source code

Another cool microcontroller project from jesper. Counter measurer using microcontroller AT 90S2313, you can use ATtiny 2313 to replace it. It could be a simple digital counter count up at 35-40Mhz.The software written in C code.

“It uses only 4 chips – 3 HC TTL’s and an Atmel At90S2313 microcontroller. It has a 5 digit LED display plus one used as a band indicator. Even with the LED display, the current consumption is less than 50 mA. It counts up to at least 52 MHz. I couldn’t find any signal source in the lab that could supply more than 52 MHz, so it may go a bit higher, but the fClock(typ) for the HC590 is about 35-40 MHz, so you shouldn’t really count (no pun intended) on more.”

Schematic

Source Code for counter measurer

/*
Jesper Hansen

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.

Project: CounterMeasures

40 MHz Frequency Counter
————————

CPU : At90S2313

Date: 2001-03-02

Author : Jesper Hansen

Current consumption about 40-45 mA.

Measures to > 50 MHz

*/

#include
#include
#include

// PORT D bits

// al counter control bits active low

#define CLEAR PD6
#define OE_H PD5
#define OE_L PD4

// PD3..0 is lower data bus

// PORT B

// PB7..4 is high data bus
// PB3 is OC1 output
// PB2..0 is 74HC138 select bits for display common

// constants/macros
#define F_CPU 4000000 // 4MHz processor
#define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond

// display data

#define SEG_a 0×01
#define SEG_b 0×02
#define SEG_c 0×04
#define SEG_d 0×08
#define SEG_e 0×10
#define SEG_f 0×20
#define SEG_g 0×40
#define SEG_dot 0×80

unsigned char digits[] = {
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f), // 0
(SEG_b|SEG_c), // 1
(SEG_a|SEG_b|SEG_d|SEG_e|SEG_g), // 2
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_g), // 3
(SEG_b|SEG_c|SEG_c|SEG_f|SEG_g), // 4
(SEG_a|SEG_c|SEG_d|SEG_f|SEG_g), // 5
(SEG_a|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g), // 6
(SEG_a|SEG_b|SEG_c), // 7
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g), // 8
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_f|SEG_g), // 9

(SEG_a), // mode 0 indicator (Hz)
(SEG_g), // mode 1 indicator (kHz)
(SEG_d), // mode 2 indicator (MHz)
};

/****************************************************************************/

// timer 0 interrupt handles multiplex and refresh of the displays
// timer is clocked at 62500 Hz

#define TI0_L (256-125) // 500 Hz -> 2 mS

volatile unsigned char active_led = 0;

volatile unsigned long led_value = 0; // four BCD nibbles
volatile unsigned char decimal_point = 0;
volatile unsigned char mode_setting = 0;

SIGNAL(SIG_OVERFLOW0) //timer 0 overflow
{
unsigned char a,b;

// reload timer
outp(TI0_L, TCNT0);

// all displays off by setting all commons high
outp(inp(PORTB) | 0×07, PORTB);

if (active_led == 5)
{
b = digits[10 + mode_setting];
}
else
{
a = led_value >> (( 4 – active_led ) * 4);

b = digits[a & 0x0f];

if (decimal_point == (4 – active_led) )
b |= SEG_dot;
}

a = b & 0xf0; // hi part
b = b & 0x0f; // lo part

// set digit data on port
outp( (inp(PORTB) & 0x0f) | a, PORTB); // high part
outp( (inp(PORTD) & 0xf0) | b, PORTD); // low part

// set common
outp( (inp(PORTB) & 0xf8) | active_led, PORTB);

active_led = (active_led+1) % 6;
}

/****************************************************************************/
/* helpers ****************************************************************/
/****************************************************************************/

void delay(unsigned short us)
{
unsigned short delay_loops;
register unsigned short i;

delay_loops = (us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty)

// one loop takes 5 cpu cycles
for (i=0; i < delay_loops; i++) {};
}

//
// read 16 bit counter value
//
unsigned int read_counters(void)
{
unsigned int counter_value;

// stop display refresh while reading counters
cli();

// turn off all segments
outp(inp(PORTB) | 0×07, PORTB);

// set high B port to input
outp(0x0f,DDRB);

// set low D port to input
outp(0xf0,DDRD);

// activate OE_H
cbi(PORTD,OE_H);
asm volatile(“nop”);
sbi(PORTD,OE_H); // one pulse to latch count
asm volatile(“nop”);
cbi(PORTD,OE_H);
asm volatile(“nop”);

// read hi
counter_value = (inp(PINB) & 0xf0);
// read lo
counter_value |= (inp(PIND) & 0x0f);
// deactivate OE_H
sbi(PORTD,OE_H);

counter_value <<= 8;

// activate OE_L
cbi(PORTD,OE_L);
asm volatile(“nop”);
sbi(PORTD,OE_L); // one pulse to latch count
asm volatile(“nop”);
cbi(PORTD,OE_L);
asm volatile(“nop”);

// read hi
counter_value |= (inp(PINB) & 0xf0);
// read lo
counter_value |= (inp(PIND) & 0x0f);
// deactivate OE_L
sbi(PORTD,OE_L);

// set B port back to output
outp(0xff,DDRB);

// set D port back to output
outp(0xff,DDRD);

// re-enable display refresh
sei();
return counter_value;
}

//
// do a capture
//
void capture(unsigned int compare)
{

cbi(PORTD,CLEAR); // clear external counters
asm volatile(“nop”);
sbi(PORTD,CLEAR); // remove clear

outp(0,TCNT1H); // clear timer
outp(0,TCNT1L);

outp(compare >> 8,OCR1H); // set the compare1 register to the
outp(compare,OCR1L); // required value

outp(0×40,TCCR1A); // set OC1 bit to toggle on compare

sbi(TIFR,OCF1A); // clear overflov/compare flags

if (compare == 15625)
outp(0x0C,TCCR1B); // start with fClk/256 (15625 Hz) and compare clear
else
outp(0x0A,TCCR1B); // start with fClk/8 (500 kHz) and compare clear

while ( ! (unsigned char) ( inp(TIFR) & BV(OCF1A)) ); // wait for bit
sbi(TIFR,OCF1A); // clear flags

// counter input now enabled
// for the specified time

while ( ! (unsigned char) ( inp(TIFR) & BV(OCF1A)) ); // wait again for bit

outp(0,TCCR1B); // stop timer

// counter input disabled
}

/****************************************************************************/
/* main *******************************************************************/
/****************************************************************************/

int main(void)
{
int i,j;
unsigned char dp,ms;
unsigned long lv;
unsigned int count;

// set all PORTB as outputs
outp(0xff,DDRB);

// set all bits hi
outp(0xff,PORTB);

// set all PORTD as outputs
outp(0xff,DDRD);

// set all bits hi
outp(0xff,PORTD);

// setup timer 0

outp(0×03, TCCR0); // prescaler f/64 tPeriod = 1/62500 Hz -> 16 uS

// enable timer 0 interrupt
sbi(TIMSK, TOIE0);

// start things running
sei();

/*
compare values at fclk/8 (500 kHz, 2 uS) :

500 = 1 mS
5000 = 10 mS
50000 = 100 mS

at fclk/256 (15.625 kHz, 64 uS) :

15625 = 1 S

*/

// first make sure the OC1 pin is in a controlled state
// we want it to be HIGH initially

// There’s no way to set/clear it directly, but it can be forced to
// a defined state by a compare match, se by setting a low compare value
// and start the timer, it can be forced into set state

outp(0,TCNT1H); // clear timer
outp(0,TCNT1L);

outp(0,OCR1H); // set compare to 200
outp(200,OCR1L);

outp(0xC0,TCCR1A); // set OC1 bit to set on compare

// start timer and wait for one compare match
outp(0×01,TCCR1B); // start with fClk/1 (4 MHz)
while ( ! (unsigned char) ( inp(TIFR) & BV(OCF1A)) ); // wait for bit
sbi(TIFR,OCF1A); // clear flags

outp(0,TCCR1B); // stop timer

// compare bit no HI, start
// doing some useful work

while (1)
{
// try a capture at min gate
capture(500); // 1 mS
// get the data
count = read_counters();
dp = 3; // decimal point
ms = 2; // indicate MHz

if (count < 4096) // less than 4.096 MHz
{
// try a capture at next gate value
capture(5000); // 10 mS
// get the data
count = read_counters();
dp = 4; // decimal point
ms = 2; // indicate MHz

if (count < 4096) // less than 409.6 kHz
{
// try a capture at next gate value
capture(50000); // 100 mS
// get the data
count = read_counters();
dp = 3; // decimal point
ms = 1; // indicate kHz

if (count < 4096) // less than 40.96 kHz
{
// try a capture at next gate value
capture(15625); // 1 S
// get the data
count = read_counters();
dp = 0; // decimal point
ms = 0; // indicate Hz
}
}
}

// convert BINARY counter_value (int) to BCD in led_value (long)
lv = 0;
for (j=0;j<8;j++)
{
i = count % 10;
lv >>= 4;
lv |= ((unsigned long)i << 28);
count /= 10;
}

// set display variables
decimal_point = dp;
mode_setting = ms;
led_value = lv;

} // loop

}

S:electronicsuite.com

AT 90S2313 microcontroller based AVR digital counter with Source code

Another cool microcontroller project from jesper. Counter measurer using microcontroller AT 90S2313, you can use ATtiny 2313 to replace it. It could be a simple digital counter count up at 35-40Mhz.The software written in C code.

“It uses only 4 chips – 3 HC TTL’s and an Atmel At90S2313 microcontroller. It has a 5 digit LED display plus one used as a band indicator. Even with the LED display, the current consumption is less than 50 mA. It counts up to at least 52 MHz. I couldn’t find any signal source in the lab that could supply more than 52 MHz, so it may go a bit higher, but the fClock(typ) for the HC590 is about 35-40 MHz, so you shouldn’t really count (no pun intended) on more.”

Schematic

Source Code for counter measurer

/*
Jesper Hansen

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place – Suite 330, Boston, MA 02111-1307, USA.

Project: CounterMeasures

40 MHz Frequency Counter
————————

CPU : At90S2313

Date: 2001-03-02

Author : Jesper Hansen

Current consumption about 40-45 mA.

Measures to > 50 MHz

*/

#include
#include
#include

// PORT D bits

// al counter control bits active low

#define CLEAR PD6
#define OE_H PD5
#define OE_L PD4

// PD3..0 is lower data bus

// PORT B

// PB7..4 is high data bus
// PB3 is OC1 output
// PB2..0 is 74HC138 select bits for display common

// constants/macros
#define F_CPU 4000000 // 4MHz processor
#define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond

// display data

#define SEG_a 0×01
#define SEG_b 0×02
#define SEG_c 0×04
#define SEG_d 0×08
#define SEG_e 0×10
#define SEG_f 0×20
#define SEG_g 0×40
#define SEG_dot 0×80

unsigned char digits[] = {
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f), // 0
(SEG_b|SEG_c), // 1
(SEG_a|SEG_b|SEG_d|SEG_e|SEG_g), // 2
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_g), // 3
(SEG_b|SEG_c|SEG_c|SEG_f|SEG_g), // 4
(SEG_a|SEG_c|SEG_d|SEG_f|SEG_g), // 5
(SEG_a|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g), // 6
(SEG_a|SEG_b|SEG_c), // 7
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g), // 8
(SEG_a|SEG_b|SEG_c|SEG_d|SEG_f|SEG_g), // 9

(SEG_a), // mode 0 indicator (Hz)
(SEG_g), // mode 1 indicator (kHz)
(SEG_d), // mode 2 indicator (MHz)
};

/****************************************************************************/

// timer 0 interrupt handles multiplex and refresh of the displays
// timer is clocked at 62500 Hz

#define TI0_L (256-125) // 500 Hz -> 2 mS

volatile unsigned char active_led = 0;

volatile unsigned long led_value = 0; // four BCD nibbles
volatile unsigned char decimal_point = 0;
volatile unsigned char mode_setting = 0;

SIGNAL(SIG_OVERFLOW0) //timer 0 overflow
{
unsigned char a,b;

// reload timer
outp(TI0_L, TCNT0);

// all displays off by setting all commons high
outp(inp(PORTB) | 0×07, PORTB);

if (active_led == 5)
{
b = digits[10 + mode_setting];
}
else
{
a = led_value >> (( 4 – active_led ) * 4);

b = digits[a & 0x0f];

if (decimal_point == (4 – active_led) )
b |= SEG_dot;
}

a = b & 0xf0; // hi part
b = b & 0x0f; // lo part

// set digit data on port
outp( (inp(PORTB) & 0x0f) | a, PORTB); // high part
outp( (inp(PORTD) & 0xf0) | b, PORTD); // low part

// set common
outp( (inp(PORTB) & 0xf8) | active_led, PORTB);

active_led = (active_led+1) % 6;
}

/****************************************************************************/
/* helpers ****************************************************************/
/****************************************************************************/

void delay(unsigned short us)
{
unsigned short delay_loops;
register unsigned short i;delay_loops = (us+3)/5*CYCLES_PER_US; // +3 for rounding up (dirty)

// one loop takes 5 cpu cycles
for (i=0; i < delay_loops; i++) {};
}

//
// read 16 bit counter value
//
unsigned int read_counters(void)
{
unsigned int counter_value;

// stop display refresh while reading counters
cli();

// turn off all segments
outp(inp(PORTB) | 0×07, PORTB);

// set high B port to input
outp(0x0f,DDRB);

// set low D port to input
outp(0xf0,DDRD);

// activate OE_H
cbi(PORTD,OE_H);
asm volatile(“nop”);
sbi(PORTD,OE_H); // one pulse to latch count
asm volatile(“nop”);
cbi(PORTD,OE_H);
asm volatile(“nop”);

// read hi
counter_value = (inp(PINB) & 0xf0);
// read lo
counter_value |= (inp(PIND) & 0x0f);
// deactivate OE_H
sbi(PORTD,OE_H);

counter_value <<= 8;

// activate OE_L
cbi(PORTD,OE_L);
asm volatile(“nop”);
sbi(PORTD,OE_L); // one pulse to latch count
asm volatile(“nop”);
cbi(PORTD,OE_L);
asm volatile(“nop”);

// read hi
counter_value |= (inp(PINB) & 0xf0);
// read lo
counter_value |= (inp(PIND) & 0x0f);
// deactivate OE_L
sbi(PORTD,OE_L);

// set B port back to output
outp(0xff,DDRB);

// set D port back to output
outp(0xff,DDRD);

// re-enable display refresh
sei();
return counter_value;
}

//
// do a capture
//
void capture(unsigned int compare)
{

cbi(PORTD,CLEAR); // clear external counters
asm volatile(“nop”);
sbi(PORTD,CLEAR); // remove clear

outp(0,TCNT1H); // clear timer
outp(0,TCNT1L);

outp(compare >> 8,OCR1H); // set the compare1 register to the
outp(compare,OCR1L); // required value

outp(0×40,TCCR1A); // set OC1 bit to toggle on compare

sbi(TIFR,OCF1A); // clear overflov/compare flags

if (compare == 15625)
outp(0x0C,TCCR1B); // start with fClk/256 (15625 Hz) and compare clear
else
outp(0x0A,TCCR1B); // start with fClk/8 (500 kHz) and compare clear

while ( ! (unsigned char) ( inp(TIFR) & BV(OCF1A)) ); // wait for bit
sbi(TIFR,OCF1A); // clear flags

// counter input now enabled
// for the specified time

while ( ! (unsigned char) ( inp(TIFR) & BV(OCF1A)) ); // wait again for bit

outp(0,TCCR1B); // stop timer

// counter input disabled
}

/****************************************************************************/
/* main *******************************************************************/
/****************************************************************************/

int main(void)
{
int i,j;
unsigned char dp,ms;
unsigned long lv;
unsigned int count;

// set all PORTB as outputs
outp(0xff,DDRB);

// set all bits hi
outp(0xff,PORTB);

// set all PORTD as outputs
outp(0xff,DDRD);

// set all bits hi
outp(0xff,PORTD);

// setup timer 0

outp(0×03, TCCR0); // prescaler f/64 tPeriod = 1/62500 Hz -> 16 uS

// enable timer 0 interrupt
sbi(TIMSK, TOIE0);

// start things running
sei();

/*
compare values at fclk/8 (500 kHz, 2 uS) :

500 = 1 mS
5000 = 10 mS
50000 = 100 mS

at fclk/256 (15.625 kHz, 64 uS) :

15625 = 1 S

*/

// first make sure the OC1 pin is in a controlled state
// we want it to be HIGH initially

// There’s no way to set/clear it directly, but it can be forced to
// a defined state by a compare match, se by setting a low compare value
// and start the timer, it can be forced into set state

outp(0,TCNT1H); // clear timer
outp(0,TCNT1L);

outp(0,OCR1H); // set compare to 200
outp(200,OCR1L);

outp(0xC0,TCCR1A); // set OC1 bit to set on compare

// start timer and wait for one compare match
outp(0×01,TCCR1B); // start with fClk/1 (4 MHz)
while ( ! (unsigned char) ( inp(TIFR) & BV(OCF1A)) ); // wait for bit
sbi(TIFR,OCF1A); // clear flags

outp(0,TCCR1B); // stop timer

// compare bit no HI, start
// doing some useful work

while (1)
{
// try a capture at min gate
capture(500); // 1 mS
// get the data
count = read_counters();
dp = 3; // decimal point
ms = 2; // indicate MHz

if (count < 4096) // less than 4.096 MHz
{
// try a capture at next gate value
capture(5000); // 10 mS
// get the data
count = read_counters();
dp = 4; // decimal point
ms = 2; // indicate MHz

if (count < 4096) // less than 409.6 kHz
{
// try a capture at next gate value
capture(50000); // 100 mS
// get the data
count = read_counters();
dp = 3; // decimal point
ms = 1; // indicate kHz

if (count < 4096) // less than 40.96 kHz
{
// try a capture at next gate value
capture(15625); // 1 S
// get the data
count = read_counters();
dp = 0; // decimal point
ms = 0; // indicate Hz
}
}
}

// convert BINARY counter_value (int) to BCD in led_value (long)
lv = 0;
for (j=0;j<8;j++)
{
i = count % 10;
lv >>= 4;
lv |= ((unsigned long)i << 28);
count /= 10;
}

// set display variables
decimal_point = dp;
mode_setting = ms;
led_value = lv;

} // loop

}

S:electronicsuite.com

PIC16F628 Microcontroller based Frequency Counter (16Hz to 100Hz)

This is 16Hz to 100Hz Frequency Counter by PIC16F628 Microcontroller project, building a basic and low cost frequency counter circuit. It can measure from 16Hz to 100Hz signals with a maximum amplitude of 15V. The sensitivity is high, the resolution is 0.01Hz. The input signal can be a sine, a square or a triangle waveform.

The counter can be used in many applications. For instance, to observe an oscillator’s accuracy, to measure the mains frequency or to find out the rpm of a motor that is connected to an encoder.

The CCP (Capture/Compare/PWM) module of the PIC microcontroller counts the input signal. Only the capture function is used. To learn more about the CCP module of the PIC please visit www.microchip.com.

The displays are 14.2 mm common cathode seven segment LEDs with red light.

Before measuring the frequency of the input signal, the signal must be converted to the square waveform. So an optical isolator circuitry with 4N25 optocoupler is used for this purpose. So the input signal is safely isolated from the microcontroller circuit and converted to square wave. The signal amplitude must not exceed 15V. If this happens, 1k resistor may burn. If you want to measure the mains frequency, you should use a 220V/9V transformer first.

The supply voltage should be between 8-12V. Since the circuit may be defected, you should be careful about the polarity while connecting the supply.

The counter circuit schematic is given in the project file. There are 4 displays that are driven by the multiplexing method. To make the measurement, the RB3 pin is connected to the output of the optic isolator. The second display’s 5 numbered pin is connected to the supply via 1K resistor so the dot after the second display brights. This connection isn’t shown in the schematic.

The C code that is writen with Hi-tech PIC C compiler, the hex code is also included.

We used extra two sockets. One (18 pin, 2 way) is for the PIC16F628 microcontroller, and the other one is (40 pin, 2 way) for the seven segment displays.

  • 1 x PIC16F628 – 04/P Microcontroller
  • 4 x Common Cathode 7 Segment Display
  • 1 x 4N25 General Purpose Phototransistor Optocoupler
  • 5 x BC547 NPN Transistor
  • 1 x 7805 Voltage Regulator
  • 7 x 330 Ohm 1/4 W Resistor
  • 7 x 1K 1/4 W Resistor
  • 1 x 470 Ohm 1/4 W Resistor
  • 1 x 10K 1/4 Resistor
  • 1 x 4.7K 1/4 W Resistor
  • 1 x 1N4148 Diode
  • 2 x 220nF Polyester Capacitor
  • 2 x 22pF Ceramic Capacitor
  • 2 x 100uF 16V Electrolytic Capacitor
  • 1 x 4Mhz Crystal Oscillator

S:electronicsuite.com

Typical Applications for 2-Way Multiplexed LCD Drive with COP8 Microcontrollers

2-Way Multiplexed LCD Drive and Low Cost A/D Converter Using V/F Techniques with COP8 Microcontrollers

This application note is intended to show a general solution for implementing a low cost A/D and a 2-way multiplexed LCD drive using National Semiconductor’s COP840C 8-bit microcontroller. The implementation is demonstrated by means of a digital personal scale. Details and function of the weight sensor itself are not covered in this note. Also the algorithms used to calculate the weight from the measured frequency are not included, as they are too specific and depend on the kind of sensor used.

Typical Applications

  • Weighing scales
  • Sensors with voltage output
  • Capacitive or resistive sensors
  • All kinds of measuring equipment
  • Automotive test and control systems

Features

  • 2-way multiplexed LCD drive capability up to 30 segments (4 digit and 2 dot points)
  • Precision frequency measurement
  • Low current consumption
  • Current saving HALT mode
  • Additional computing power for application specific tasks.
  • SOURSE:electronicsuite.com


PIC16F684 Microcontroller and ACS712 based 3 Digits Digital Ammeter

This is a 3Digits Digital Ammeter using PIC16F684 Microcontroller and ACS712 current sensor. The measured DC or AC current will display on 3 digits 7-segment with resolution 100 mA.

The current sensor in this project is ACS712ELCTR-30A-T from Allegro(I got from ebay). It can measure the AC or DC current up to 30A with 66 mV/A output sensitivity.

The microcontroller PIC16F684 reading analog value from the ACS712 current sensor output and convert to curent for diplaying on 7-segment. All 7-segments are commond anode type and driven by pnp transistor . Actually, this circuit suitable for measuring DC current e.g. solar panel to battery, battery to load.

S:electronicsuite.com

pic16f84a microcontroller for digital thermometer


This electronic project is a very simple thermometer that is based on the PIC16F84A microcontroller, designed by Microchip.
Why to use a thermometer that is designed using a microcontroller and not a classic analog thermometer? Because you can design a complex solution using few external components, resulting an low cost application that provide a high precision measurement .
This Digital thermometer microcontroller project use watchdog timer function to measure temperature. The WDT on all PIC-micro microcontrollers has a nominal time-out period of 18 ms. The WDT time-out period varies with temperature, VDD and part-to-part process variations.
Without using a separate temperature sensor, it is possible to calculate the temperature with reasonable accuracy using the WDT time-out period.
To translate the environment temperature into an actual reading, the system must be able to do the following:
• Provide a method for establishing time-out to temperature calibration
• Count the number of WDT time-outs for a given period of time
• Equate the number of time-outs to a temperature
The PIC16F84A microcontroller is normally in SLEEP mode, consuming
very little operating current but if any key is pressed, it ‘wakes up’ from SLEEP and updates the WDT count, and checks for additional key presses. If there are none, it returns to SLEEP mode.
The WDT Thermometer has three distinct operating modes:
SLEEP Mode: This is the default mode the system starts in when power is applied .
Display Mode: When the TEMP key is pressed, the system wakes up and the LEDs show the temperature
in degrees Centigrade.
Calibration Mode: This mode creates a set of new calibration values, in addition to those present in the firmware.
To calibrate the device you must to:
1. Place the system in the temperature forcing system at the higher of the two calibration temperatures, and wait 5 minutes for the temperature to stabilize.
2. Press and hold the SET key while apply ing power to the system.
3. Press either the UP or DOWN key to increase or decrease the displayed temperature setting by one degree to match the actual temperature.
4. Press the SET key. The new high temperature calibration is stored in data EEPROM.
5. Change the temperature of the forcing system to the low calibration temperature (allow 5 minutes for the temperature to stabilize).
6. Press either the UP or DOWN key to increase or decrease the displayed temperature setting by one degree to match the current temperature.
7. Press the SET key. The new low temperature calibration is stored in data EEPROM, and the firmware sets a flag (Default) to indicate that new calibration information is available.
8. To return to the pre-programmed calibration at any time during this process, press the TEMP key

PIC16F688 Based Digital Voltmeter with a PIC mictocontroller

Circuit diagram

This project describes how to make a digital voltmeter with a PIC microcontroller. A character based on HD44780 LCD display is used to measure voltage. The PIC microcontroller used in this project is PIC16F688, which has 12 I / O pins of which 8 can be used as analog input channels to the built-in 10-bit ADC. The measured voltage is fed to one of eight analog channels.

The reference voltage for the AD conversion is chosen to be the supply voltage Vdd (+5 V). A resistor divider network is used to end the inning with a map of the range of input voltage range of ADC input voltage (0-5 V). The technique can show that the input voltage from 0 to 20 V, but can be expanded with an appropriate choice of resistance and make the calculation described below.

Since the PIC port can not be directly 20V input, the input voltage is reduced by using a resistor divider network simple. The resistors R1 and input voltage range R2-range of 0-20V to 0-5V, before being implemented in PIC16F688 channel analog input AN2. 5.1V zener diode connected in parallel between the port pin AN2 and earth provides protection to the PIC pin input voltage is accidentally beyond 20V. The LCD screen is connected to the 4-bit mode, and the head of CPSI makes firmware development easier than you can reprogram and test the PIC while it is on. When you’re happy and you want to transfer the circuit of the test card to a PCB or prototyping board for general purposes, it is not necessary ICSP header.
S:

a digital frequency counter created with AT89c2051 & an LCD display

With a microcontroller system AT89c2051 and an LCD display we can create a digital frequency counter which can measure frequencies up to 250KHz. LCD is used LM16200.


LCD LM16200
LM16200 LDC Pic

Table LM16200.
Pin LCD LM16200

Scheme of frequency counter digital using AT89c2051 are as follows:
Frekuensi Counter DigitalSkema Rangkaian Frekuensi Counter Digutal

AT89c2051 to program, we use the Bascom 8051, the following programs Frequency caunter Digital Using AT89c2051:


'--------------------------------------------------------
' file: efy20fm24.BAS 25-12-05
' Frequency Meter Program using AT89c2051 micro controller
' written using bascom-51 from www.mcselec.com holland
' an embedded visual basic compiler for 8051 micro
' controllers
' by K.S.Sankar Web: www.mostek.biz
'------------------------------------------------------
' Connect the timer0 input P3.4 to a frequency generator
' with 24 mhz xtal accuracy ok upto 250khz
' define crystal speed and include file
$regfile = "89c2051.dat"
$crystal = 24000000
' define variables used
Dim A As Byte
Dim C As Long , D As Long
Dim Count As Word
Dim T0ic As Long
Dim Delayword As Word

' Initialize variables
Count = 0
T0ic = 0
D = 0
' initialize ports
P1 = 0
P3 = 255
' configure lcd display
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = P1.4 , Db5 = P1.5 , Db6 = P1.6 , Db7 = P1.7 , E = P1.3 , Rs = P1.2
Cls
'clear the LCD display
Lcd " EFY Freq Meter "
' define timer0
Config Timer0 = Counter , Gate = Internal , Mode = 1
'Timer0 = counter : timer0 operates as a counter
'Gate = Internal : no external gate control
'Mode = 1 : 16-bit counter
' set t0 internal interrupt
On Timer0 Timer_0_overflow_int
' interrupt will be generated on every 65536 count
Priority Set Timer0
Enable Interrupts
Enable Timer0

Counter0 = 0
'clear counter
Start Counter0
'enable the counter to count
Do
'set up a 1 sec accurate DO NOTHING loop
Enable Interrupts
'wait 1 as per BASCOM-51 is not accurate
For Delayword = 1 To 45440
Next Delayword
Disable Interrupts
C = Counter0
'get counter value
D = T0ic * 65536
Lowerline
C = C + D
T0ic = 0
Lcd " "
Lowerline
' show the frequency
Lcd "f=" ; C ; " Hz"
Waitms 255
Waitms 255
C = 0
Counter0 = 0
Start Counter0
're-start it because it was stopped by accessing the COUNTER
Loop

' timer0 int subroutine
Timer_0_overflow_int:
Rem timer0 overflow ( 65535 ) interrupt comes here
' increment the variable
Incr T0ic
Return
End
' end of program
' uses 1106 bytes of program memory

Secured RSA for Credit card Transaction System


The project aims to take credit card input from the terminal and sends it to the server controller and outputs to the server PC monitor by designing a credit card transaction system with RSA encryption.

Explanation

The project utilizes two microcontrollers with one on the storefront terminal. This is responsible for taking the account number and the transaction amount from the store clerk through the keypad as they are displayed on the LCD when typed. Using UART software, a key pair will be requested from the server. After waiting for the server to respond, it will loop though the account and the cash amount data as well as encrypting and sending it to the server one bit at a time. The data is decrypted after being received by the server before storing into its memory. The contents are dumped to the PC hyperterminal when the memory overflows.

The bank operator is allowed by the server to perform simple functions as well as change keys for better security by going down one entry in its list of stored keys and a different pair is used. The transaction system works successfully.

S: www.electronicsprojects.mediadir.in

Measuring distance covered by bicycle and Rangkaian Pengukur Jarak

This circuit Can be Used to Measure distance covered by bicycle using a reed switch as the sensor and use the magnet tied to a wheel. Detection of rolling is then made by a proximity effect, Pls the magnet close to the reed switch. This close / open reed switch contact Can use to make on-off signal. 68HC908QY4 microcontroller function for counting the pulse signal Produced by reed switches, and then Direct display in meter unit through lcd 16 x 1 line LCD

 Pengukur Jarak Prototipe Pengukur Jarak Prototipe

Rangkaian Pengukur JarakSkema rangkaian pengukur jarak

To Interface signals for LCD are D4-D7, RS and E. 4-bit It was interfacing, no busy checking. D0-D3 and R / W # is not Used, so We must tie to GND. Since We Can not check Busy bit, so the delay routine must be ready LCD Used to wait for command and writing data. The sensor inputs are PTA2 for reed switch contact and PTA0 for 0 / +5 V analog input can use a small phone jack for both sensors. in the image below shows a sample sensor and cable making. Later shrinkage tube We need to protect the sensor. The position sensor Pls Pls fix to the bicycle wheel Also Important. We need the magnetic flux perpendicular to the contact.

sensor and cable making

Software/program

Software for write to68HC908QY4 microcontroller is s-record.hex ,which was written by C-language ,the source code is firmware source code.

source http://chaokhun.kmitl.ac.th

PIC18F452 used to create the personal Radar System


It’s a great hobby project although the schematic is very complicated. This project uses three main devices to create the personal radar system.
The IR Range sensor gives output, the pic microcontroller processes it and then displays the output on the led array.

PIC16F628 microcontroller used in a new project fastest finger


It is a new project Fastest Finger with microcontroller PIC16F628 . This simple circuit has five buttons and five LEDs. Four keys are linked with players, the fifth provides manual reset. After switching on or after reset (reset, manual or automatic), all the LED off and the system is ready. One of four players who were consigned to quickly see the button of its own LED light and all other keys are immediately blocked.

S: www.electronics-lab.com

Advertisement