Click here to Skip to main content
15,885,366 members
Articles / Programming Languages / C

c8051 Module

Rate me:
Please Sign up or sign in to vote.
4.00/5 (4 votes)
30 Mar 2010CPOL2 min read 20.1K   175   12  
c8051 module for Frequency inverter

Introduction

This module is for controlling frequency inverter. We all know that for controlling rotation frequency of the motor, all inverters have interface connector for 'Frequency setting potentiometer'. Sadly all the cheap inverters don't have the possibility to set speed of motor to exact value, according to speed potensiometer. This article describes a method of getting around this limitation (using Silabs C8051F300 MCU).

IMG002_s.JPG
View large module

mashine2.JPG

Background

This is a working- tested module for the plastic machinery, which makes plastic trashbag's which are sold anywhere in construction shops. When I was working as an electrical technician in such an industry, to speed up the production line, I attached this module to the machine.

By attaching this module, I gain update speed even upto 2 times, compared to the previous one.

shematic2.JPG

Using the Code

In the code header, we set 'count'- count of bags, when reached- starts decelerate to speed, pointed in 'MAX_CAN_READ'.
To avoid tearing bags apart from each other, module includes protection value 'LEVEL'.

'MAX_SPEED' is limited to ADC (Analog Digital Converter) output value, which is dependant on MCU Supply Voltage(VDD). C8051F300 supply voltage ranges from 2.7 to 3.6VDC.

Port I/O (Input-Output) Output High Voltage = VDD – 0.7
To set up 'count' - while holding down 'RED' button choose with 'UP' or 'DOWN' desired value.

Timer1 is responsible for updating UART output. Timer0 for reading switch 1, 2 state and updating GREEN LED state. ADC interrupt updates the output voltage and UART buffer. For power losses, count value is stored in flash address '1A00'.

The main routine looks like this:

C++
void main (void) 
{
   PCA0MD &= ~0x40;                	// WDTE = 0 (clear watchdog timer 
                                    	// enable)
   SYSCLK_Init ();               	// Initialize system clock to 
                                    	// 24.5MHz
   PORT_Init ();                    	// Initialize crossbar and GPIO
   Timer_Init();                    	// Init Timer2 to generate 

   ADC0_Init();                     	// Initialize ADC0
   UART0_Init();                    	// Initialize UART0 for printf's
//-------
		YELLOW_LED_STATE = BLINK_OFF;
		count = FLASH_ByteRead(0x1A00);
		if (count > 25) count = 25;
//-------
PCA_Init();
CR      = 1;                  	// Start PCA Counter
   EIE1      = 0x0C;
   EA = 1;			// enable global interrupts
   while (1) 
   {		
		
		if (RED == 0)
		{			
			if (YELLOW_LED_STATE == SOLID_OFF) count_blinks=0;
			if(count_blinks < count)
			{
				YELLOW_LED_STATE = BLINK_SLOW;		
			}
			else
			{		
				YELLOW_LED_STATE = BLINK_OFF;
			}
						
		}else
		{		
			YELLOW_LED_STATE = SOLID_OFF;
			if(count_blinks > count) override_flag = TRUE;
			else override_flag = FALSE;
		}

		if (upd_flag == TRUE)
		{
			erase_flash_page();
			FLASH_ByteWrite(0x1A00, count);
			upd_flag = FALSE;
		}
   }
}

Other Articles

Please take a look at my other articles listed below:

There, you can find instructions to update Silabs MCU-s with USB-Toolstick.

History

  • 30th March, 2010: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Estonia Estonia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --