EMBEDDED TWEAKS

Embedded Electronics Tutorials, Coding and lot more

GUI based advance product counting machine

This system is ideal for companies which have many manufacturing units.. The system mainly works to help the manufacturing unit to get data of current product quantity and to process this data. In this whole article I am taking example of a company which manufactures pipes. So here product1, product2, product3 … in this article can be circular pipe, triangular pipes, square pipes etc… Many types of pipes.

Conventionally, the company’s manufacturing plants use the product counters to count their product quantity manufactured. Normally these types of systems are equipped with 7-segment displays. Hence whenever the company boss wants to see the product’s current quantity, each time he has to go to each product line and note that data.

Hence we have made an innovative and a very user friendly automatic computerized system for above issues. We collect data from all the product line sensors together and  display it on a computer screen of the company boss. We have made PIC16f887 microcontroller based hardware for all these tasks.

Functional blocks are as shown below:

diagram

This software is made in Microsoft Visual BASIC 6.0. Its screenshot is as above. And it provides the following facilities to the manufacturing unit’s boss:

  • So he gets real time data of the product quantity counted every second. Now he doesn’t need to go to each product line and note down the data.
  • Every orders and product quantity data is stored in a safe database and displayed on screen and updated with interval of every 10 seconds. So we can check past data on anytime whenever required.
  • Boss can also generate an Excel file of the product data of the whole day with just 1 click. These details can be useful for the account section staff, because they can calculate the data of every day and use it with ease.
  • This software requires a User name and password. So only authenticated persons can start and use this software.
  • Almost no extra human resources needed due to everything automatic and computerization, Hence corruption is also stopped.

The circuit diagram is as shown in the proteus simulation here.

ckt

 In the block diagram the object sensors are shown,they are made using IR leds and photodiode pairs. They are mounted on the conveyor belts.  They are easily available in the market or even easy to make it at home.

infrared-obstacle-avoidance-sensor-module-e96303d3-800x800

Anyhow one thing will be same that that sensor will toggle to logic ‘0’ or ‘1’ when the passed through the belt. Hence for simplicity i gave taken 4 switches in place of sensors for the purpose of simulation. when the switch is pressed it means product is passed through, it returns logic ‘0’. Hence the corresponding command will be sent via the serial port, which can be decoded in PC.

The code written in MPLAB X is shown as below.

#include <xc.h>
#include <GenericTypeDefs.h>
#include “usart_pic16.h”
#include “LCD.h”
// Configuration Byte
#pragma config FOSC = HS // Oscillator Selection bits (HS oscillator)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = ON // Power-up Timer Enable bit (PWRT enabled)
#pragma config MCLRE = OFF // RE3/MCLR pin function select bit (RE3/MCLR pin function is digital input, MCLR internally tied to VDD)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = ON // Brown Out Reset Selection bits (BOR enabled)
#pragma config IESO = OFF // Internal External Switchover bit (Internal/External Switchover mode is disabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is disabled)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)

// CONFIG2
#pragma config BOR4V = BOR40V // Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off)

#define SENSOR0 RB0
#define SENSOR1 RB1
#define SENSOR2 RB2
#define SENSOR3 RB3

void main()
{
unsigned int a,b,c,d,s0,s1,s2,s3 = 0;
unsigned int digit1, digit2, digit3, digit4;

//Initialize USART with baud rate 9600
USARTInit(9600);
//Write intro text
LCDInitialize();
OPTION_REGbits.nRBPU = 0;
WPUB = 0XFF;
ANSELH = 0x00;
TRISB = 0x0F;
LCDWriteString(“Initializing..”);
__delay_ms(300);
LCDRow2();
LCDWriteString(“Testing LCD”);
__delay_ms(700);

LCDClear();
LCDWriteString(“Ready…..”);
__delay_ms(700);

LCDClear();
LCDWriteString(” ***Welcome***”);
__delay_ms(700);

LCDClear();
LCDWriteString(“P0: “);
LCDWriteString(“P1: “);
LCDRow2();
LCDWriteString(“P2: “);
LCDWriteString(“P3: “);
USARTWriteString(“Incoming Product data is:rn”);
a = 0;
b = 0;
c = 0;
d = 0;
while(1)
{
if(!s0 ||!s1 || !s2 || !s3)
{
if(SENSOR0)
s0 = 1;
if(SENSOR1)
s1 = 1;
if(SENSOR2)
s2 = 1;
if(SENSOR3)
s3 = 1;
__delay_ms(70);
}
if(s0)
{
if(!SENSOR0)
{
s0 = 0;
a++;
digit1 = (unsigned int)(a/1000); // Calculate digit1 of ADC_value
digit2 = (unsigned int)((a – digit1*1000)/100); // Calculate digit2 of ADC_value
digit3 = (unsigned int)((a – (digit1*1000+digit2*100))/10); // Calculate digit3 of ADC_value
digit4 = (unsigned int)(a – (digit1*1000+digit2*100+digit3*10)); // Calculate digit4 of ADC_value
LCDWriteCommand(0x83);
LCDWriteData(digit2+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit3+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit4+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
USARTWriteString(“Product0 quantity updated : “);
USARTWriteChar(digit2+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit3+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit4+0x30); // Display digit4 of ADC_value on UART
__delay_ms(10);
USARTWriteString(“.rn”);
}
}
if(s1)
{
if(!SENSOR1)
{
s1 = 0;
b++;
LCDWriteCommand(0x8D);
digit1 = (unsigned int)(b/1000); // Calculate digit1 of ADC_value
digit2 = (unsigned int)((b – digit1*1000)/100); // Calculate digit2 of ADC_value
digit3 = (unsigned int)((b – (digit1*1000+digit2*100))/10); // Calculate digit3 of ADC_value
digit4 = (unsigned int)(b – (digit1*1000+digit2*100+digit3*10)); // Calculate digit4 of ADC_value
LCDWriteData(digit2+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit3+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit4+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
USARTWriteString(“Product1 quantity updated : “);
USARTWriteChar(digit2+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit3+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit4+0x30); // Display digit4 of ADC_value on UART
__delay_ms(10);
USARTWriteString(“.rn”);
}
}
if(s2)
{
if(!SENSOR2)
{
s2 = 0;
c++;
LCDWriteCommand(0xC3);
digit1 = (unsigned int)(c/1000); // Calculate digit1 of ADC_value
digit2 = (unsigned int)((c – digit1*1000)/100); // Calculate digit2 of ADC_value
digit3 = (unsigned int)((c – (digit1*1000+digit2*100))/10); // Calculate digit3 of ADC_value
digit4 = (unsigned int)(c – (digit1*1000+digit2*100+digit3*10)); // Calculate digit4 of ADC_value
LCDWriteData(digit2+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit3+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit4+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
USARTWriteString(“Product2 quantity updated : “);
USARTWriteChar(digit2+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit3+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit4+0x30); // Display digit4 of ADC_value on UART
__delay_ms(10);
USARTWriteString(“.rn”);
}
}
if(s3)
{
if(!SENSOR3)
{
s3 = 0;
d++;
LCDWriteCommand(0xCD);
digit1 = (unsigned int)(d/1000); // Calculate digit1 of ADC_value
digit2 = (unsigned int)((d – digit1*1000)/100); // Calculate digit2 of ADC_value
digit3 = (unsigned int)((d – (digit1*1000+digit2*100))/10); // Calculate digit3 of ADC_value
digit4 = (unsigned int)(d – (digit1*1000+digit2*100+digit3*10)); // Calculate digit4 of ADC_value
LCDWriteData(digit2+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit3+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
LCDWriteData(digit4+0x30); // Display digit1 of ADC_value on LCD
__delay_ms(1);
USARTWriteString(“Product3 quantity updated : “);
USARTWriteChar(digit2+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit3+0x30); // Display digit3 of ADC_value on UART
__delay_ms(1);
USARTWriteChar(digit4+0x30); // Display digit4 of ADC_value on UART
__delay_ms(10);
USARTWriteString(“.rn”);
}

}
}
}

 This is for the simplest version just sending strings as per product on the serial port. But if you know JAVA, VB6, VB.NET or any other language very well then you can also create a nice GUI in that. here in the video i am showing my software developed in VB6. In that At loading time, we need to configure the COM port as follow :

‘ Fire Rx Event Every single Bytes
MSComm1.RThreshold = 1

‘ When Inputting Data, Input 1 Byte at a time
MSComm1.InputLen = 1

‘ 9600 Baud, No Parity, 8 Data Bits, 1 Stop Bit
MSComm1.Settings = “9600,N,8,1”
‘ Disable DTR
MSComm1.DTREnable = False

‘ Open COM1
MSComm1.CommPort = 1
MSComm1.PortOpen = True

The we wait for the data coming on our serial port i.e., MSComm1. for that we are writting following code. Immediately on getting data we, store it in to a variable called as data. Then we process it to check conditions.

If MSComm1.CommEvent = comEvReceive Then
Data = MSComm1.Input ‘get data
If Data = “A” Then
i = i + 1
Label1.Caption = i ‘convert to ASCII and display
ElseIf Data = “B” Then
j = j + 1
Label2.Caption = j
ElseIf Data = “C” Then
k = k + 1
Label3.Caption = k
ElseIf Data = “D” Then
l = l + 1
Label4.Caption = l
End If
End If
End Sub

Here is a snapshot for that

Capture

You can view the full video here.

Sharing is caring

26 Comments

  1. I savour, cause I found exactly what I was taking a look for. You’ve ended my 4 day long hunt! God Bless you man. Have a nice day. Bye

  2. Whats up very nice site!! Man .. Excellent .. Wonderful .. I will bookmark your website and take the feeds also¡KI am happy to seek out numerous helpful information here in the publish, we need develop more strategies in this regard, thank you for sharing. . . . . .

  3. I consider something genuinely interesting about your blog so I saved to fav.

  4. I’ll immediately clutch your rss as I can not find your e-mail subscription link or e-newsletter service. Do you’ve any? Please let me know in order that I may just subscribe. Thanks.

  5. I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.

  6. My hubby and I really want to tell you in which I’m really inexperienced to blogging and certainly adored your work. Very possible I am inclined to remember your web post . You really have fabulous content stuff. Appreciate it for expressing with the two of us your web document.

  7. I personally liked up to you’ll receive performed right here. The information is neat, your very own written message is remarkable.

  8. web host you’re {utilizing|working

  9. After looking into a few of the articles on your website, I seriously like your way of writing a blog. I bookmarked it to my bookmark site list and will be checking back soon. Take a look at my website too and let me know how you feel.|

  10. I simply hope to notify you that I am new to putting up a blog and really enjoyed your site. Very possible I am most likely to bookmark your blog post . You simply have excellent article content. Like it for giving out with us your favorite web document

  11. That is very attention-grabbing, You’re an overly professional blogger. I’ve joined your feed and look forward to in search of more of your wonderful post. Also, I’ve shared your web site in my social networks|

  12. Great post. I used to be checking constantly this blog and I am inspired! Extremely helpful info specifically the ultimate section 🙂 I handle such info much. I was seeking this particular information for a very long time. Thanks and best of luck. |

  13. Perfect work you have done, this site is really cool with great info .

  14. Hey very nice website!! Man .. Beautiful .. Amazing .. I’ll bookmark your website and take the feeds also…I am happy to find numerous useful information here in the post, we need develop more strategies in this regard, thanks for sharing. . . . . .

  15. My partner liked as much as you will obtain performed proper here. The work is attractive, your created content is fantastic.

  16. Good – I should definitely pronounce, impressed with your website. I had no trouble navigating through all tabs as well as related info ended up being truly easy to do to access. I recently found what I hoped for before you know it at all. Quite unusual. Is likely to appreciate it for those who add forums or anything, website theme . a tones way for your client to communicate. Excellent task.

  17. I was recommended this blog through my cousin. I am not positive whether this put up is written by him as no one else recognize such distinct approximately my problem. You are wonderful! Thank you!

  18. I just want to say I’m all new to blogging and really enjoyed your web site. Most likely I’m likely to bookmark your blog post . You actually come with really good stories. Thank you for sharing your web page.

  19. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why waste your intelligence on just posting videos to your weblog when you could be giving us something enlightening to read?

  20. Hello my friend! I wish to say that this article is awesome, nice written and include almost all significant infos. I would like to see more posts like this.

  21. Very interesting info !Perfect just what I was searching for! “Justice delayed is justice denied.” by William Gladstone.

  22. It’s the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I want to suggest you few interesting things or tips. Perhaps you could write next articles referring to this article. I want to read more things about it!

  23. I simply want to mention I am just newbie to blogging and site-building and seriously savored you’re blog site. Almost certainly I’m going to bookmark your blog post . You amazingly come with fantastic posts. Thanks a lot for sharing your webpage.

  24. I just want to tell you that I’m new to blogs and certainly savored your blog. More than likely I’m going to bookmark your blog post . You really have perfect stories. Appreciate it for sharing your webpage.

Leave a Reply

Your email address will not be published.

*

© 2018 EMBEDDED TWEAKS

Theme by Anders NorenUp ↑

Follow Me

Get the latest posts right delivered in you mailbox

%d bloggers like this: