Atmega board and example code for bowling application

Go To Last Post
18 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello everybody,

 

hopefully somebody can support me. I want to start to use Atmega boards and work with it. In this Special case I want to build a Special Bowling application.

Goal is it to get a detector with 39 sensors (to detect the single lines/lanes). there will be a Display (7-segment) as Output  to Show the result.

 

As sensors I’m using an IR Obstacles Avoid Sensor (39 pcs) with low signal as detection of something (high signal without anything).

My plan was to use a Atmega128 development board - due to the 39 inputs and 13 outputs
inputs from 39 sensors, outputs for 13 signals to the 7-segment (only 13 because I do not use the left upper segment on the 2nd number - because I do not need to display a 4, 6, 8, 9, 0 -- only 1, 2, 3 as ).

 

1.question: do anybody prefers to another (better) development board or usual board or can I use the mentioned board? Do you have any suggestions?!

 

I want to use the board always with the same “program”, so no further updates of the chip needed (if the program is running).

 

Plan is: if the bowling ball is detected by one of the sensor, the display should show the number of lane for round about 10 seconds. If two sensors detect a low signal, the lower number should be shown.

 

I have some experiences with VBA but never programed an Atmega. For my first steps I used an arduino uno to control some LEDs, but I did not tried to use some inputs likes sensors.

2.question: Do anybody have a simple program or have part of codes for 1 example - means, the code for 1 sensor input and control 1 output. I really hope I need to copy this code for the other sensors and define the inputs and output with the quantity of sensors I have, isn’t it?

 

Many thanks in advance!

 

Rg
From Germany
Sven

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

Greetings and Welcome to AVR Freaks.

 

Almost everyone here will recommend one of the Arduino boards. Inexpensive, pretty easy to use. But, the relatively small number of IO pins would require rethinking how your arrange your hardware.

 

39 sensors are a challenge in any system. Eight parallel input shift registers connected to the MCU's SPI port would handle them fairly easily. The display is otherwise pretty straight forward and there is lots of Arduino code for a huge variety of displays. 

 

Hope this gives you some alternate ideas.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

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

As Jim says the "quick start" these days are Arduino. If you need the kind of resources (esp lots of IO) that the ancient old 128 would have offered get an Arduino Mega which is based on the mega2560

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

How far away from your AVR board with the sensors be?  I'm thinking you may need something like an RS-485 connection for your sensors.

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

As an avid bowler/instructor this has me interested......

 

39 sensors?  Usually in league and competition you use a pair(2) lanes so for 20 lanes you need 40 sensors.

 

All you want to do is detect the ball crossing a point on the lane?  Use a narrow beam IR emitter and likewise detector and place them across the lane at the desired point.

 

Are you trying to determine what pins are left standing after each ball is delivered?  THats a different scenario.  Modern lanes can use either a camera, or a laser to detect what pins are standing for each delivery.  If you want to keep things simple I would place a small rare earth magnet at the bottom of each pin, and place a magnetic reed switch in each pins resting position on the pin deck.  Scan the deck after each ball delivery.

 

Will you be keeping score?

 

 

THis has the potential of becoming a really cool project!!

 

East Coast Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

Hello,

 

thanks for the first answers.

 

@Jim - we want to improve our bowling game and try to hit a certain point. I want to have 2 detector-jigs. 1 at the beginning of the track and 1 at the end of the oil pattern. It's important to hit the correct break point that you get a nice aley for the pins. So correct I want to detect the call crossing. For this I have a jig with 39 sensors (1 - 20 - 1, in sum 39 single lines).

 

I attache 2 pictures, 1 schematic how it should be and 1 picture of the real jig (current status)

 

@kk6gm - the distance between the sensors is round about 2,7cm, in total 1,06m + round about 50cm to the board. 

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

So the sensors are arrayed across the width of the lane?  And are they located at the pin end of the lane, or at the player end, or somewhere in between?  If the display board is far from the players, are you just going to use giant numerals to be easy to read, rather than bringing the display board up close to the players?

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

gothscherknoten wrote:
I want to have 2 detector-jigs. 1 at the beginning of the track and 1 at the end of the oil pattern.

 

Ahh, but is the oil pattern the SAME each time?  Nope.  So how do you calibrate your rig to adjust?  By the way  nice jig you set up there!

 

Also, are you trying to gauge where the ball 'breaks' in the oil pattern?  If yes, then you are in for several issues. 

 

1) how teh ball is drilled will dictate when it will 'break'  Early, late etc.

2) the bowler themself.  The amount of finger action applied to the ball at launch/delivery, the amount of 'push' the bowler applied to the ball all make a difference to the 'break' point in the oil pattern.

 

gothscherknoten wrote:
It's important to hit the correct break point that you get a nice aley for the pins.

That comes from PRACTICE with your ball and your learning what I outlined above.  At the centre I bowl at I ask what the pattern is and they tell me....sometimes....Before league play starts we get 5 minutes practice to 'learn' the lanes we are on.

 

But keep in mind that the pattern changes as the game(s) progress, with the oil getting pushed down the lane, and picked up by the ball, which is usually wiped down after each delivery so the pattern at the beginning, and at the halfway mark, and the tenth frame is different.

 

How does your rig compensate for the analog changes that occur?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

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

What comes to mind for me is this might be an ideal application for machine vision as the field of interest is fairly small and constrained. Also the use of a scanning LIDAR might help.

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

Kartman wrote:
this might be an ideal application for machine vision
+1

 

And if so then you may want to take a look at https://www.avrfreaks.net/forum/... which would make a great platform for doing object recognition in real time. You would need to learn to use OpenCV for such a solution though. If you prefer Python to C++ (many do!) then that's catered for too:  https://pypi.org/project/opencv-wrapper/

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

Cool project.

 

Take it a step at a time.

 

You've flashed an LED, that's a good start.

 

I'd suggest you use the same Uno you have already worked with and hook up one sensor, and use it to control the LED.

 

Then work on your display.

 

Then put it all together.

 

You really have to decide whether you wish to do this using the Arduino "language", or use another language, (C, Basic, etc.).

 

Even if you use C or Basic or something else, you can still use the Arduino hardware.

 

JC

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

Hello,

 

sorry for the late answers. Many thanks for all your comments etc.

I want to Show and answer again some comments and questions.

 

Ahh, but is the oil pattern the SAME each time?  Nope.  So how do you calibrate your rig to adjust?  By the way  nice jig you set up there!

 

the oil pattern is not the same all the time, that*s why it should be adjustable. Please see following schematic.

the first jig should be around the arrows, the 2nd one at the end of the oil pattern. The jig itself can be adjusted in the width (within the alu Frame). the height can be adjusted throug some screws in the Frame. The sensors itself are always in the same range, but can be adjusted to the right and left (you can see it in the Picture from the old post, the sensors are mounted to the White plastic Frame. this one is adjustable with scres on the alu Frame). so it's always possible to adjust the senor Frame (on the plastic) to get the correct Position over the lane.

 

That comes from PRACTICE with your ball and your learning what I outlined above. 

 

yes of course this come from practise, but exact this I want to practise :-) I want to see, if I hit my planned Point (at the beginning of the lane and at the end of the pattern. The jig should be something for practise.

 

What comes to mind for me is this might be an ideal application for machine Vision

yes, seems to be the same, but detection in parallel.

 

Hopes this helps for a better understanding.

 

@DocJC

I'm flexible for the language, but of course I want to understand what I'm doing there. For me it's the first Project, but in the next couple of month I plan to do more Projects also for my home, the garden etc.

Currently I have a Kind of plan how to generate the code, but I'm not sure. I will try to write the code by myself, but of course If somebody have parts for my code (e.g. the part to get the sensor signals, ot the part to control the Display) it would be helpful.

 

Thanks for the Moment and maybe somebody have any ideas for my code.

 

rg

:-)

 

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

Hello again,

 

there was a marriage inbetween ;-)

 

so I have my first code available, but I don't know if this is usable or not. As explanation:

- I have 39 sensors, first sensor detects panel 39, 39th sensor detects panel 01

- I have 13 digits in total -- xy (6 for the  x and 7 for the y) -- see also the attachement

- this is not complete, i have to copy it for all off the other imputs and outputs.

 

please be aware:

this is my first code for an Atmega128 and I have several questions for it:

how to declare the in/outouts to a special pin on the board? currently I do not know it! -- > problem (see ???)

is this everything I have to take care about it?

 

 

/*
 * This is my first Arduino code for Atmega128
#define sensor01 PF7
#define sensor02 ???
… // this will be filled up
#define sensor10 ???
#define sensor11 ???
#define sensor12 ???
… // this will be filled up
#define sensor39
#define leda1
#define leda2
#define ledb1
#define ledb2
#define ledc1
#define ledc2
#define ledd1
#define ledd2
#define lede1
#define lede2
#define ledf2
#define ledg1
#define ledg2
 
void setup () {
serial.begin(9600);
pinMode(sensor01, INPUT);
pinMode(sensor02, INPUT);
… // this will be filled up
pinMode(sensor10, INPUT);
pinMode(sensor11, INPUT);
pinMode(sensor12, INPUT);
… // this will be filled up
pinMode(sensor39, INPUT);
pinMode(leda1, OUTPUT);
pinMode(leda2, OUTPUT);
pinMode(ledb1, OUTPUT);
pinMode(ledb2, OUTPUT);
pinMode(ledc1, OUTPUT);
pinMode(ledc1, OUTPUT);
pinMode(ledd1, OUTPUT);
pinMode(ledd2, OUTPUT);
pinMode(lede1, OUTPUT);
pinMode(lede2, OUTPUT);
pinMode(ledf1, OUTPUT);
pinMode(ledg1, OUTPUT);
pinMode(ledg2, OUTPUT);
}
 
void loop() {
 // this is 1 example for 1 sensor (panel39)
int sen01 = digitalRead(sensor01);
int sen02 = digitalRead(sensor02);
int sen03 = digitalRead(sensor03);
int sen04 = digitalRead(sensor04);
… // this will be filled up
int sen39 = digitalRead(sensor39);
 
if(sen01 == LOW) {
 // sensor01 is detecting over panel39, so output will be 39 (first number = first digit)
    digitalWrite(leda1,HIGH);
    digitalWrite(ledb1,HIGH);
    digitalWrite(ledc1,HIGH);
    digitalWrite(ledd1,HIGH);
    digitalWrite(ledg1,HIGH);
    digitalWrite(leda2,HIGH);
    digitalWrite(ledb2,HIGH);
    digitalWrite(ledc2,HIGH);
    digitalWrite(ledd2,HIGH);
    digitalWrite(ledf1,HIGH);
    digitalWrite(ledg2,HIGH);
 
delay(10000); //output for 10 sec.

 

 

It would be very helpful to get a code for my Atmega128.

 

 

many thanks in advance!

 

 

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

You have to provide numbers with those "leda1" definitions. Simply #define is not adequate. You need to do something like

 

#define leda1 5

Not that familiar with details  of Arduino, but I think  the number you use is the board's GPIO number for that pin. Check the definition of the pinMode() function to see what it requires. digitalWrite() will have exactly the same requirement.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Aug 24, 2019 - 06:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for the hint, this was what I'm looking for.

 

I added it now, but I'm not sure if the void setup and void loop is correct or not.

 

a short feedback would be pretty nice :-)

 

/*
 * This is my first Arduino code for Atmega128
#define sensor01 2
#define sensor02 3
… // this will be filled up
#define sensor10 11
#define sensor11 12
#define sensor12 13
… // this will be filled up
#define sensor 50
#define leda1 18
#define leda2 55
#define ledb1 19
#define ledb2 56
#define ledc1 33
#define ledc2 57
#define ledd1 34
#define ledd2 58
#define lede1 51
#define lede2 59
#define ledf2 60
#define ledg1 54
#define ledg2 61

 

void setup () {
serial.begin(9600);
pinMode(sensor01, INPUT);
pinMode(sensor02, INPUT);
… // this will be filled up
pinMode(sensor10, INPUT);
pinMode(sensor11, INPUT);
pinMode(sensor12, INPUT);
… // this will be filled up
pinMode(sensor39, INPUT);
pinMode(leda1, OUTPUT);
pinMode(leda2, OUTPUT);
pinMode(ledb1, OUTPUT);
pinMode(ledb2, OUTPUT);
pinMode(ledc1, OUTPUT);
pinMode(ledc1, OUTPUT);
pinMode(ledd1, OUTPUT);
pinMode(ledd2, OUTPUT);
pinMode(lede1, OUTPUT);
pinMode(lede2, OUTPUT);
pinMode(ledf1, OUTPUT);
pinMode(ledg1, OUTPUT);
pinMode(ledg2, OUTPUT);
}

 

void loop() {
 // this is 1 example for 1 sensor (panel39)
int sen01 = digitalRead(sensor01); //panel39
int sen02 = digitalRead(sensor02); //panel38
int sen03 = digitalRead(sensor03); //panel37
int sen04 = digitalRead(sensor04); //panel36
… // this will be filled up
int sen39 = digitalRead(sensor39); //panel01

if(sen01 == LOW) {
 // sensor01 is detecting over panel39, so output will be 39 (first number = first digit)
    digitalWrite(leda1,HIGH);
    digitalWrite(ledb1,HIGH);
    digitalWrite(ledc1,HIGH);
    digitalWrite(ledd1,HIGH);
    digitalWrite(ledg1,HIGH);
    digitalWrite(leda2,HIGH);
    digitalWrite(ledb2,HIGH);
    digitalWrite(ledc2,HIGH);
    digitalWrite(ledd2,HIGH);
    digitalWrite(ledf1,HIGH);
    digitalWrite(ledg2,HIGH);

delay(10000); //output for 10 sec.
}

 

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

I would just give you a general idea if you are going to/ you would like to replace your arduino sketch. so normally you would provide a function for initializing the inputs/outputs, say:

 


//include all the headers at the beginning 

#include <.....>
#include <.....>

//make your definitions to make it easier for you to read the code

#define ledo1 

//here you can put your functions prototypes

void io_init(void);

//here add your global variables

volatile uint16_t g_something = 0;

//here put the ISR, lets say an RTC vect

ISR(RTC_PIT_vect)
{
    //ISR
}

//functions
void io_init(void)
{
    //here you initialize all you i/o pins digital...analog...etc
}

//main

int main(void)
{
    io_init();

    //and so on

    while(1){

        //what should your program do....
    }
}

 

this is a general structure...ofcurse it depends from a person to person. but I think you should look for some tutorials online, in this forum there is a very helpful section (Tutorials)

 

Regards,

 

Moe

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

gothscherknoten wrote:
delay(10000); //output for 10 sec.

 

a 10 sec delay has a lot of drawback, It means that you are blocking the processor from doing anything else for 10 sec, so nothing is running in the background. a more wise way is to use timers.  RTC would do the work and it has much less power consumption compared to a dealy. a nice way to see it is to use an osci...

 

 

Last Edited: Mon. Aug 26, 2019 - 08:01 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for the hint!

I think, It's OK to use the delay, because the usage show that I don't throw the next ball in this time period.

For other usages I would prefer to use timers!

 

thanks!