Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

c8051 Module

0.00/5 (No votes)
30 Mar 2010 1  
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:

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here