Looking for appropriate sensors for medium diploma graduation projects

Go To Last Post
60 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wolfrose wrote:
I tried to write what pops into my head but I did a quick search and it turns out the this strategy belongs to C++, and I have to be familiar with classes properties and features to know about this method. But in its simplest form I think it's the getter function in C++.    

 

Why would I suggest it as an option if it was C++ only? Why did you need to search - I basically gave you the answer - all you had to do was fill in the function. Again, you've chosen to overlook a learning opportunity. Somehow I think we've been through the same process before....

 

Kartman wrote:
You'd normally do digit multiplexing in a timer interrupt. Using soft timers will lead to brightness modulation.

You've still not done this, but then again, you're using an i2c expander. Considering you can get i2c devices that do the display multiplexing for you or even non i2c devices. These can be got for little money off ebay. Doing it via an i2c expander is making a rod for your own back. If you make poor choices you spend inordinate amounts of time trying to fix the issues you've created rather than going for a sensible solution that just works.

 

 You've also not looked at how you can simplify your code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

2. write an accessor function. Something like setTaskTimer(uint8_t task, uint32_t time); Make that function visible to all your files

 

#2 is the technically more correct solution. Can you suggest why?

 

OK, so I think this could be done this way:

 

1. By developing this function in the multitasking library as an "extern".

2. Then any function in the other libraries should have an extra parameter with the time amount.

3. Register the functions address and store it in an enum.

 

How about that?

 

 

 

 

Kartman wrote:

Why would I suggest it as an option if it was C++ only? Why did you need to search - I basically gave you the answer - all you had to do was fill in the function. Again, you've chosen to overlook a learning opportunity. Somehow I think we've been through the same process before....

 

OK, if so then I think what you meant is to develop a function that is visible to all the libraries by defining it as "extern", I just pass the task number, and I think at this point I have to use function pointers. I tried to think of a way to register the function address in any library and store them in an array or enum.

 

 

Kartman wrote:
You've still not done this, but then again, you're using an i2c expander. Considering you can get i2c devices that do the display multiplexing for you or even non i2c devices. These can be got for little money off ebay. Doing it via an i2c expander is making a rod for your own back. If you make poor choices you spend inordinate amounts of time trying to fix the issues you've created rather than going for a sensible solution that just works.

Well, anyway we must use this board now, because there's no time to order any good breakout boards from eBay or Aliexpress. I know about these things and I absolutely love them, I normally don't do things in my own soldering but this was because I was thinking to do counters using 74LS47, 2 PNP transistors, 8 resistors and 2 common anode 7-segment displays.

 

But you absolutely right that was a come back to me because the trainees didn't know how to fix them as I was hoping to, so the fixing was my job and it took quite amount of time fixing soldering issues, absolutely my mistake. All my personal stuff are breakout boards from Aliexpress. But anyway I should learn from this mistake and try to prepare things to be easy for me and not expecting a lot from the trainees.

 

 You've also not looked at how you can simplify your code.

Hmmmm this is the best thing I could do about the code, what you suggest? Run all the displays with one timer interrupt?

 

 

===========================================================================================================

 

These are the boards, upto this level I think it's acceptable, but of course looking to improve it.

 

 

Last Edited: Sun. Dec 2, 2018 - 12:59 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I think you’re guessing - how do you store something in an enum? If the task is to store a value into an array, then you’re way off track. Think simple.

Did you really use 74ls47’s? I was ten years old when I last used them. Then you’ve used an i2c expander. You like doing things the hard way.

As for simplifying the display code - look for repeating bits of code. And use a switch statement.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
I think you’re guessing - how do you store something in an enum? If the task is to store a value into an array, then you’re way off track. Think simple.
OK, I'm working on this new task to develop a function which I think it could a function which receives pointers to other functions. That's my guess.

 

 

Did you really use 74ls47’s? I was ten years old when I last used them.

 Yeah absolutely! We have a lot of old chips on the components' compartments in the electronics store room in the college, they recently ordered EEPROMs! How about that?

 

That's why I used these old ICs because they are in stock and this is a good chance for me to use them. One of my mistakes when I wanted to get into electronics control projects is that I ordered the basic logic gates and similar ICs before actually getting an Arduino and other microcontrollers in general. And as a result those ICs are in my electronics box doing nothing! And then I started to work with the 74hc595 then I moved to the MAX7219 bare chips. Then I ordered the complete MAX7219 dot matrix breakout board.

 

So in regard to the college, I asked them to order a lot of Arduinos for the projects. And they listened to me so the current projects are done with Arduino boards which is a good thing for basic simple projects.

 

Then you’ve used an i2c expander. You like doing things the hard way.

 Yeah that was my decision for multiplexing, I thought it was a good choice and it's working now, I've used this module for other stuff in the projects; like, controlling 3-way traffic light system, and that saved us good amount of pins of the Arduino board. And here I'm multiplexing the 3 boards with one i2c expander.

 

As for simplifying the display code - look for repeating bits of code. And use a switch statement.

 OK, thanks for the advice.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Why are you guessing? I gave you the answer! I have no idea of why you are thinking about function pointers!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Mr Kartman,

 

 

I have a little problem with an IR and the 7-segment module.

 

The issue is that I'm developing a function which is based on people counting technology and I found that this technology is actually popular in systems which is required to count people in malls, centers .. etc.

 

My setup is simple, two IRs counting the entering and exiting states and update the counting on the 7-segment boards. The problem is when the IR detects the ACTIVE/LOW signal, the tens digit just go off!

 

It turns out that the reason is because of the flag register. Here's the code:

void IR_people_counting_set(void){
	if(!digitalRead(IR_1)&&(ir1_tri==0)&&(ir2_tri==0)&&(exiting_state==0)){
		ir1_tri=1;   // <--- This is the problem, when I comment the 7-segemnt
		             // 2nd digit works OK
	}

	/*if(!digitalRead(IR_2)&&(ir1_tri==1)&&(ir2_tri==0)&&(entering_state==0)){
		ir1_tri=0;
		entering_state = 1;
		IR_count_reset_start_millis = millis();
	}	

	if(!digitalRead(IR_2)&&(ir1_tri==0)&&(ir2_tri==0)&&(entering_state==0)){
		ir2_tri=1;
	}

	if(!digitalRead(IR_1)&&(ir2_tri==1)&&(ir1_tri==0)&&(exiting_state==0)){
		ir2_tri=0;
		exiting_state = 1;
		IR_count_reset_start_millis = millis();
	}*/
}

I commented the rest of the code because I was debugging the code.

 

 

 

==================================================================

 

Note: I'm not forgetting about your task to me which is to develop a function accessor to setup the time for any function in other libraries, but now because I'm working on the college projects which are obviously in Arduino coding.

 

But the task you asked me to do is for my own C multitasking project.

Last Edited: Wed. Dec 5, 2018 - 08:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can see a reference to a flag but not a flag register. Why do you think the problem is in this code?
The problem I have is trying to make sense of your code - there is four tests of binary values so that gives at least 16 possibilities. Trying to map that out in my head is rather difficult. I would have to spend time with a pencil and paper to reverse engineer your code. Alternately, i could just re-engineer the solution. Apart from ‘solving’ your problem for you, you would not oearn anything. You have mentioned many times you wish to learn.
I dare say most of us here would draw a state diagram before even thinking of writing code. This forms documentation of how we expect the system to operate. We would then translate this into code. This is software engineering.

Your code has a handful of flags - the reality is only a small number of combinations of them are valid. I gather you can’t have both entering-state and exiting-state true at the same time. Mix in the other flags and the combinations multiply. Before long the average human brain cannot keep track of all of them and has got too complex. The art of programming is to make the complex simple.

Since i have little idea about how uou want your system to work, the following is my guess:
You have five states-
1. Idle. No sensors detected
2. Sensor 1 detected-enter
3. Sensor 2 detected-enter
4. Sensor 2 detected-exit
5. Sensor 1 detected-exit

You can have 1 variable to represent these 5 states. You then write the code to change between these states based on the inputs and time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The acessor function is one line of code in a function. Equally applicable in Arduino or C.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This year's unbounded patience award awarded to Russell for heroic advice above and beyond the call of duty!
.
My favourite quote in this thread was the one about just writing what pops into the head. That, right there, is a perfect summary of why this thread will be interminable.

Pages