This is the main, and possibly final entry on the open-access project I participated in. I have linked all the previous parts of this series at the bottom and will add a link to this page at the bottom of those entries once it’s published. The last state this was in before I gave up on ever using this project in production was to include a beaglebone white as the network connection with scripts for pushing and pulling data out of the arduino mega controller. No part of this was ever successfully completed due in part to the rapidly aging support and documentation for the beaglebone white making it all but unusable as part of a modern project without a particular interest and knowledge of using it. The OpenAccess 4.0 did exactly what we planned on doing, but with a pi.
In this entry I will be going over what is needed to operate this project in its most complete state. The two files that are designed to work together are this one on the uart lcd and this one on the arduino mega. The front panel controller was discussed in a previous article, the last one is what we’re here to discuss.
Here are some odd little functions in the code:
int freeRam(void)
{
extern int __bss_end;
extern int *__brkval;
int free_memory;
if((int)__brkval == 0) {
free_memory = ((int)&free_memory) – ((int)&__bss_end);
}
else {
free_memory = ((int)&free_memory) – ((int)__brkval);
}
return free_memory;
}
I had a serious problem with memory leaks, that function helped me find them.
char *ftoa(char *a, double f, int precision)
{
long p[] = {
0,10,100,1000,10000,100000,1000000,10000000,100000000 };char *ret = a;
long heiltal = (long)f;
itoa(heiltal, a, 10);
while (*a != ‘\0’) a++;
*a++ = ‘.’;
long decimal = abs((long)((f – heiltal) * p[precision]));
itoa(decimal, a, 10);
return ret;
}
This function converts a float to a character array, I had so much trouble printing floats you have no idea…
// This gets set as the default handler, and gets called when no other command matches.
void unrecognized()
{
Serial.println(“What?”);
}
This is, well, it responds to unknown serial commands with this.
// reads battery voltage
void check_battery()
{
battery_start = millis();
float voltage = ((float)(analogRead(A15)*20)/1024.0);
if(voltage<voltage_threshold)
{
battery_dur = (1000*60*5); //set to 2 mins
logging(logDate());
logging(” – “);
loggingln(“battery voltage dropped below threshold”);
}
else
{
battery_dur = (1000*60*15); //set to 1 hour
}char volt[8];
ftoa(volt,voltage,2);
//dtostrf(voltage,8,2,volt); should work?
printname = “Battery voltage: “;
printname += volt;logging(logDate());
logging(” – “);
loggingln(printname);
}
That checks the battery voltage and is run on command or periodically (the period increases decreases as the battery drops in voltage).
//battery stuff
float voltage_threshold = 13.6; //threshold to throw an error at
unsigned long battery_start = 0; //used for count down timer
unsigned long battery_dur = (1000*60*15); //time between battery checks (fifteen minutes default)
Battery declaration stuff, sets when to check more often (and alarm) and the variables where the timer is stored.
I broke the rest of the code up into sub-articles. They all link back here, and here’s the index of them:
- Serial commands
- I/O functions
- main logic
- privlige functions
- printer and log functions
- temperature functions
- RTC functions
- RFID functions
- LCD functions
- Keypad functions
- Exit button/relay
- eeprom functions
Recommended reading: wiki for the project, this is my non-blog documentation of this project.
Other blog entries:
arduino uart display and keypad
Other links:
July 1, 2016 at 1:26 am |
[…] Hacks, repairs, arcade games, sci-fi, and some very bad ideas with possibly humorous consequences « OpenAccess 3.0 replacement software […]
July 1, 2016 at 1:26 am |
[…] The I/O may not seem important, but it’s there so why not use it. This is part of the larger OpenAccess project. […]
July 1, 2016 at 1:30 am |
[…] That’s the salient parts of the main code. I hope that’s enough to get some of you started in the OpenAccess project. […]
July 1, 2016 at 1:32 am |
[…] The evaluation of keypresses to get into and out of those modes will be discussed elsewhere. This is part of the greater OpenAccess project. […]
July 1, 2016 at 1:33 am |
[…] This is a derivative of the dot matrix printer driver I used before and part of the OpenAccess project. […]
July 1, 2016 at 1:33 am |
[…] That variable “current_temperature” is used nowhere else and need not be declared globally. This is part of the greater OpenAccess project. […]
July 1, 2016 at 1:34 am |
[…] That’s it, that’s what the RTC is for: timestamps on things. This is part of the greater OpenAccess project. […]
July 1, 2016 at 1:34 am |
[…] This is part of the greater OpenAccess project. […]
July 1, 2016 at 1:35 am |
[…] That’s my LCD functions, you can see that I compartmentalized it a lot so it is easy to change the protocol or library of your display. This is part of the greater OpenAccess project. […]
July 1, 2016 at 1:35 am |
[…] Clearing a pin is easy, set back to unprintable. These steps are done in the key taking process which is longer and in the main logic code. This is part of the greater OpenAccess project. […]
July 1, 2016 at 1:36 am |
[…] That’s all there is to the exit button and exit relay code. It can also be called like any other relay from the I/O section, but it operates on its own unlike the others. This is part of the OpenAccess project. […]
July 1, 2016 at 1:36 am |
[…] This may seem like a lot, and you may not need much of it but I think it’s nice to have. This is part of the OpenAccess project. […]
July 1, 2016 at 12:03 pm |
[…] was implemented as an output for the future i3 Detroit rfid entry system, but can really be used anywhere 10 IO are free (or, if you want to be a little ironic, use a 74595 […]
July 1, 2016 at 12:04 pm |
[…] was to be used in the OpenAccess system, but it was abandoned like lots of other […]
July 1, 2016 at 12:07 pm |
[…] to blog more, and I keep getting side-tracked. There will be more regular updates after the Open Access Control 3.0 system is hacked together had installed at i3 Detroit, you can follow along with the updates as they are […]
July 1, 2016 at 12:08 pm |
[…] project was originally started as part of the i3 Detroit OpenAccess control system for RFID entry. I promise I’ll write an entry on that soon, but I’ve got to shake […]
July 1, 2016 at 12:08 pm |
[…] far with the OpenAccess system I’ve talked about the rs485 terminals I tried to use, a clever low pin count display and […]
July 1, 2016 at 12:09 pm |
[…] project was originally started as part of the i3 Detroit OpenAccess control system for RFID entry. I promise I’ll write an entry on that soon, but I’ve got to shake down all […]
July 1, 2016 at 12:09 pm |
[…] sci-fi, and some very bad ideas with possibly humorous consequences « Wiegand keypad OpenAccess 3.0 replacement software […]