Embedded Software Engineering C program assignment

Discussion in 'Programmer's Corner' started by Jess_88, Jul 26, 2011.

Apr 29, 2011
174
1
hey guys

Can I get a little help getting started on this project?
Here is the problem.
-----------------
I am to make a program in ANSI standard C for the following industrial process

For purposes of simplicity, the input to the process can be regarded as a random sequence of units that can be described symbolically as A, B, C and D.

* One unit arrives at the station every time unit.

* At the station is an input selector unit and four manufacturing units. The selector unit operates as follows:

° If the input unit is an A, it passes it to machine 1.

° If the input unit is a B, it passes it to machine 2.

° If the input unit is a C AND the previous unit was a B, then it passes it to machine 2

° If the input unit is a D, it passes it to machine 3.

° If the input unit is a B AND the previous unit was a D, then it passes it to machine 3.

° If the input unit is a C AND the previous unit was a B AND the unit before that was a D, it passes it to machine 3.

° Anything else is passed to machine 4.

* Machine 1 takes 1 time unit to generate an output unit V.

* Machine 2 takes 1 unit to generate an output W if the input was B. If the input was BC, it takes 2 time units and produces an output X.

* Machine 3 takes 3 time units if the input was a D and generates an output Y, but 7 if it was DBC and it produces an output Z.

* Machine 4 takes 5 time units and generates an output T.

* The outputs are queued and an output selector generates a single stream of units. After start-up, there must be one output unit generated every time unit.

-----------------------------
The main issue being how long is each queue to ensure a continuous output?

You may also note that there is no output requirement for DB... I'm guessing thats a mistake in the paper.

Here is my basic idea of how things are gonna work

Diagram of industrial process

My flowchart (its a bit rusty... just a draft)

Let me know if you don't understand something in it.

Where I'm stuck is
1) I need to display/simulate the procedure.
This confuses me... because I cant really display things visually with ANSI standard C right? Unless I just use terminal???
If there is another way to represent whats happening with the program (thats not to difficult to learn), could you please point me in the right direction.

2) The timing system
I'm not really to sure where to start
What should I be looking at to determine the length of each queue to ensure a continuous output?

Any helpful tips would be much appreciated

thanks guys

Last edited: Jul 26, 2011

Jul 7, 2009
1,585
142
Looks like a good assignment -- it will teach you some C programming and a little discrete event simulation at the same time. This is good stuff to know -- if you go into industry, you'll probably find yourself using simulations to see how stochastic systems behave, as most practical ones are easier to simulate than to figure out theoretically.

1) You have some choices. If it was me, I'd just print to the terminal, as that's the easiest. Next in complexity is using something like curses or ANSI escape sequences to use the terminal as a character display. There are GUI packages that you could build a GUI display with; some that come to mind are Qt, wxWidgets, etc. Finally, there are libraries that let you create bitmaps so you could e.g. produce a PNG file as output. All but printing to the terminal can involve significant time to learn.

2) The stochastic parts of the problem seem to be the mix of incoming units and the selection of the output unit. You're going to have to build the simulator to find out how the queues behave.

A quick way to start understanding the problem would be to use a discrete event simulation language. If it was my assignment, I'd use SymPy, as it's popular and a guy at UC Davis has written some tutorial stuff around it. Install python (a couple of minutes) and SymPy (perhaps a minute) and you're up and running. Such a tool lets you focus on the problem's behavior rather than the programming details.

In C, you're going to have to design software thingies that let you simulate the problem. It's not too hard, but it will exercise the brain muscles a bit. You'll also need to learn to use some of the random number generation facilities.

Jess_88 likes this.

Apr 29, 2011
174
1
Great!
Thanks for the info.
Time for me to get learning

4. Gigo_Don New Member

Aug 18, 2011
2
0
I find your flow chat lacking alot of details, how abt your email i send you my flow chat and we see wer we get from there?

Apr 29, 2011
174
1
I'm not sure what you mean. You don't understand my flowchart? It was just a draft to the flow of my program. See wer we get from there???

6. Gigo_Don New Member

Aug 18, 2011
2
0
working on the same project? share ideas...

Apr 29, 2011
174
1
look into some 'Queues' used in C programming. I'm just using an 'if' routine to determine the correct output and associated delay time. The output and delay are then sent to its machine (a structure containing a queue). Every repetition of this process is equivalent to one time period, which is decremented from the first element in each queue.

I'm still working on the output... I'm guessing I'll be using an output queue to prevent outputs occurring at the same time.

hope that helps.

Gigo_Don likes this.
8. djsfantasi AAC Fanatic!

Apr 11, 2010
3,547
1,289
If the input was a D, then it is one of the following 5 cases:
• DA'
• DC'
• DD'
• DB'!C"
• DB'C"
Note that the first three cases are the simple cases where the previous input was NOT a B (' indicates previous input; " indicates the input two steps before and ! indicates NOT). The last two cases are where the prior two inputs were or were not a C. This implies that the case DB'!C" should be treated as the first three cases, i.e. has a delay of 3 time units and produces an output Y.

Does this make sense?

Last edited: Aug 21, 2011

Apr 29, 2011
174
1
Yeah, that sounds about right... little confusing

another example

For the sequence ABCDBAC:
1. A is sent to machine 1. It will generate an output V after one further time unit

2. B is sent to machine 2. It will generate an output W after one further time unit.

3. C is sent to machine 2 because the previous input was a B. It will now generate an output X after 2 further time units

4. D is sent to machine 3. It will generate an output Y after 3 further time units

5. B is sent to machine 3 because the previous input was a B. It will now generate an output U after 4 time units.

6. A is sent to machine 1. It will generate an output V after one further time unit

Thus the input and output looks like this:

ABCDBA
*VW *X *Y/V **U

and hence, needs an output queue.

Apr 29, 2011
174
1
ummm... jackpercy57
Also... did you just copy and paste what I said in this thread???

11. ele2011 New Member

Sep 27, 2011
3
0
Hi guys,
I'm working on the same project and i'm stucking with the code. Could you please help me? I just want to check mine if it work properly.
Any help will be appreciated.
Thanks.
This my email: <SNIP>

Last edited by a moderator: Oct 7, 2011

Apr 29, 2011
174
1
what part are you having trouble with?

Last edited by a moderator: Oct 7, 2011
13. player07 New Member

Oct 7, 2011
1
0
hi jess ...i m working on the same assignment too and is going to the due date soon :C ... currently i still having some trouble in my coding ...do u might help me check ?? can i send to ur mail?? erm..can i ask u .what do u include in ur report ?? from my lecturer , i know implementation needed to be include..
hope to hear from you soon...

thanks

Apr 29, 2011
174
1
For the report, it doesn't really specify what is required. I am making some assumptions on some of the content. Pretty much what I'm including is;

Project requirements & limitations
Diagrams of the system (basic flow of requirements)
Code specification requirements
Code Flowcharts
Brief explanation of code
Summery of code performance
Dose the program perform as required
Summary
Printed code
Printed Simulations

This is my own understanding of what is required of the report, so don't follow everything it if you think it isn't right. If you have any recommendations about other things that should be included in the report, please let me know.

15. ele2011 New Member

Sep 27, 2011
3
0
Hi Jess_88,
Thank you for your reply. I actually have a trouble with the output of the code. Every time I execute the code I got nothing. It is like there are no inputs. Please see the attachment file. I tried to fix the error many times but i could not find it.
Thanks

16. ele2011 New Member

Sep 27, 2011
3
0
sorry, i could not attach the code but i can send it to you.