How can I convert a duration/timer to hex? - timer

I've come across a screenshot of a certain software, showing the a device's life timer like this: "96B80300 <> 000067:44". The software is not open source, it's an unofficial tool for older Nokia devices.
My question is, how do you get from "000067:44" to the "96B80300" hex value?
I am trying to change a similar timer on another device (uses only 7 digits though, like "00000:00"), and this info could be really helpful.

I can give a possible indication. If 67:44 represents hours and minutes, then the number of seconds in hex would be 67 * 60 * 60 + 44 * 60 = 243840 => 0x03B880, which allowing for big/little/whatever endian, means that it is missing 0x96 - 0x80 = 0x16 or 22 seconds. Perhaps the seconds are just not being displayed in decimal.

Related

COBOL programmers - How to use arrays

I am programming in COBOL and trying to put this client file in an array. I'm having trouble understanding this problem. I know that the array would probably be based on the bookingtype because there are 4 different options. Any help would be appreciated.
This is how I have the array defined so far:
01 Booking-Table.
05 BookingType OCCURS 4 TIMES PIC 9.
Here is the client file.
I guess the solution is about storing the costs in an array. To calculate the average the array would need to have cost + number with the booking type being the index used.
The "tricky" part may be the maximum of amount per type (9999.99) * maximum customers with this type (all and as the client number implies the 3 given positions are numeric: 1000 [including the zero, all could have the same type]).
Something like
REPLACE ==MaxBookingType== BY ==4==.
01 Totals-Table.
05 Type-Total OCCURS MaxBookingType TIMES.
10 type-amount pic 9(8)V99 COMP.
10 type-customers pic 9(4) COMP.
Now loop through the file from start to end, do check that BookingType >= 1 AND <= MaxBookingType (I'm always skeptic that "data never changes and is always correct) and then
ADD 1 TO type-customers(BookingType)
ADD trip-cost TO type-amount (BookingType)
and after end of file calculate the average for all 4 entries using a PERFORM VARYING.
The main benefit of using an "array" here is that you can update the program to have 20 booking types just by changing the value for MaxBookingType - and as you've added a check which tells you what "bad" number is seen in there you can adjust it quite fast.
I'm not sure if/how your compiler does allow self-defined numeric constants, if there's a way: use this instead of forcing the compiler to check for all occurrences of the text "MaxBookingType".
I believe the diagram is trying to say you need an enumeration. In COBOL, you'd implement this with
01 client-file-record.
*> ...
03 booking-type PIC 9.
88 cruise VALUE 1.
88 air-independent VALUE 2.
88 air-tour VALUE 3.
88 other VALUE 4.
*> ...
An array-approach is only necessary if the booking types (and/or their behaviour) varied at runtime.

What is the most efficient way to time LED’s

I need to create a board that will contain about 50 LED’s. The LED’s need to be turned on/off individually, and together (timer is based on days suppose every Monday all the 50 LED’s turn on and every day of the week 10 LED’s are turned on).
In my research I have found the LM555 timer but that would lead to a huge circuit of 50 different timers
What is the most efficient way of controlling these LED’s
My first answer was really stupid (i'm so sorry about that) and i don't know why I didn't think before about the amazing "Shift Registers".
Your Arduino don't have so much pin to light every LEDs you had. But using shift registers this is possible. From an 8-bit shift register you can light 8 LEDs using just 2-3 PIN on your Arduino board (1 for clock, 1 for data and 1 for latch).
So to light 50 PINs you just need 7 of this components (for example).
How to use it? There are a lot of tutorials on internet, usually the sparkFun tutorial is my favorite.
Below: an image from Arduino site. It explained how to connect 16 LEDs.
Anyway from the software side, what you have to know ShiftOut function.
After that you have to use time function.
First of all initialize your time variables as you can see in link I posted above.
After, in your loop:
Put HIGH your Datapin connected to 50 leds when previousMonth != month.
Put HIGH dataPin connected to 10 leds when daySum == 10 (so, when previousDay != day you have to increase daySum using daySum++).

compute the power level of ambiant noise using mems microphones

I' m using digital microphone (MEMS) on STM32 discovery board Fto record ambiant noise, and I need to know how to convert the samples amplitude to power level in dB SPL.
the microphone that I 'm using is the MP45DT02, in the datasheet the sensibility of the mic is -26 dBFS and the SNR is 61 dB
What the senstivity means is that a 94 dBSPL sine input will give a -26dBFS peak output level, or a -29 dBFS rms output level. Unless your signal is a sine wave it's probably makes more sense to use rms.
Measure the RMS of the signal.
Convert the RMS value to dBFS (dBFS = 20*log10(rms)))
Convert the dBFS value to dBSPL using the relationship of -29 dBFS = 94 dBSPL. For example, if you measured -50 dBFS then you are 21 dB down from -29. 94-21 = 83 dBSPL and there's your answer.

Encoding a timestamp to the least amount of characters

I need to create a barcode that contains, among other data, a timestamp including year, month, day, hour and minutes. Given the limited length of the code, I need this time stamp to be as short as possible.
My idea is to get the UNIX timestamp, divide by 60 (drop the "seconds" data), and then convert it into hex. Example:
Current timestamp: 1401546126
Drop the seconds: 1401546126 / 60 = 23359102
Convert to hex: 0x1646E7E
String printed to the barcode: 1646E7E
This way I can go from 10 chars to 7. I also thought of using a different base, like base 36, which can result in only 5 characters.
Is there a better way to do that, which may result in even less characters in the barcode? Is there any other approach to this problem other than converting to a higher base?
Define the lowest time you want to support and count the minutes since that time on top of dropping the seconds as you suggested. Encode that value in the base the code supports, e.g. base 43 for Code 39. 5 characters in that code allow you to represent a timespan of almost 280 years (43^5 minutes).

Data Logger PIC16F877A

I have to design a Data Logger programusing mikroC PRO to run on the EasyPIC5 board (with PIC 16F877A microcontroller). I also have to use a 2-line LCD for display.
Here is what i have been given:
The program will take measurements from Analogue Port AN0 at regular intervals, and save the raw data to
EEPROM. The user should be able to select any of 6 memory banks to store the results of a logging session,
and should be able to set the time interval between readings at 1 second, 2 seconds, 5 seconds or 10
seconds. The number of readings taken in each logging session should be set to 5, but should be alterable from a #define in the first few lines of the program. Another #define should be used to specify the total number of memory banks (set to 6).
Having quite a bit of trouble with this.
Any help would be appreciated.
EDIT
Up till now i am able to get the readings of AN0 and i write them to EEPROM.. BUT the my question which i stupidly missed to ask.. how would i set the the memory banks to 6 and how to save the logging session to any of the banks
for(i = 0; i < k; i++) // Fill data buffer
EEPROM_Write(0x00+i, i); // Write data to address 0x00
By changing the initial value of i and k you can determine where to store your data.

Resources