Project

General

Profile

Revision 11c945d9

ID11c945d9dd67425c0af61b324e31133f18d37f29
Parent fcddafaf
Child 6b6d6fda

Added by Julian Binder almost 11 years ago

added code to use the geiger counter. should count cpm. Compiles but not
tested yet.

View differences:

paintboard/code/Makefile
1
SRC = main.c twi.c motor.c servo.c sol.c
2
HDR = twi.h motor.h servo.h sol.h
1
SRC = main.c twi.c motor.c servo.c sol.c geiger.c
2
HDR = twi.h motor.h servo.h sol.h geiger.h
3 3

  
4 4
paint: paint.hex
5 5
	@
paintboard/code/geiger.c
1
#include <avr/io.h>
2
#include <avr/interrupt.h>
3
#include <stdlib.h>
4
#include "geiger.h"
5

  
6

  
7
int16_t count;
8
int16_t rate;
9
int16_t ticks;
10

  
11
void geiger_init()
12
{
13
  EICRA |= _BV(ISC11) | _BV(ISC10);
14
  EIMSK |= _BV(INT1);
15
}
16

  
17
void geiger_tick()
18
{
19
  ticks++;
20
  if(ticks==100)
21
  {
22
    ticks=0;
23
    rate = count*3;
24
    count = 0;
25
  }
26
}
27

  
28
int16_t geiger_rate()
29
{
30
  return (rate==0)?count:rate;
31
}
32

  
33
ISR (INT1_vect)
34
{
35
  count++;
36
}
paintboard/code/geiger.h
1
#ifndef _GEIGER_H_
2
#define _GEIGER_H_
3

  
4
void geiger_init();
5
int16_t geiger_rate();
6
void geiger_tick();
7

  
8
#endif 
paintboard/code/main.c
2 2
#include "motor.h"
3 3
#include "servo.h"
4 4
#include "sol.h"
5
#include "geiger.h"
5 6
#include <avr/io.h>
6 7
#include <avr/interrupt.h>
7 8
#include <util/delay.h>
......
101 102
  twi_attachSlaveTxEvent(slave_tx);
102 103
  twi_setAddress(TRACKING_ID);
103 104
  twi_init();
105
  geiger_init();
104 106
  motor_init();
105 107
  servo_init();
106 108
  while (1)
107 109
  {
110
    geiger_tick();
111
    internal_data[PAINT_INPUT_2] = geiger_rate();
108 112
    internal_data[PAINT_INPUT_1] = !(!(_BV(METAL_DETECT) & PIND));
109 113
    if (internal_data[PAINT_INPUT_1]) {
110 114
      set_servo1(-128);
......
116 120
      set_motor2(127);
117 121
    }
118 122
    servo_pulse();
119
    /* TODO geiger counter */
120 123
    _delay_ms(20);
121 124
  }
122 125
  return 0;

Also available in: Unified diff