CaptnKebec Posted August 22, 2004 Report Posted August 22, 2004 Hi Pete, Best wishes for your eyes problem. I made a little software for my radio stack and special knobs who are pressing switches to change value (turn right, press a up switch, turn left, press a down switch) the program works fine except for a strange behavior. When I use the switches to go up everything is fine but when I use it to go down, the values just keep circling in a 6 loop. Ex. 9093, 9092, 9091, 9090, 9089, 9088 and then back to 9093 Here's how the program works With each press of the down switch: 1- Reads the COM1 value from FSUIPC and put it in a variable 2- Decrease the value by one in the variable 3- Writes the COM1 value to FSUIPC It's the same for the up switch excep it increase the value. And I know you hate VB but it's written in that language!! Any clue why it's OK for up and not for down??? Thanks Michel
Pete Dowson Posted August 22, 2004 Report Posted August 22, 2004 Any clue why it's OK for up and not for down??? No, no idea, but it is likely related to something FS is doing with invalid values. After all, the only valid values for the last digit of the frequency are 0, 2, 5 and 7. Try testing the last digit and increasing/decreasing by 2 or 3 depending on the current value. Your values are hard to check in decimal. It's the hexadecimal which is important. Your "9093, 9092, 9091, 9090, 9089, 9088 and then back to 9093" are frequencies 123.85, 123.84 (invalid), 123.83 (invalid), 123.82, 123.81 (invalid), 123.80. The next time you decrement you would get the invalid 123.79. Why FS should do more with that than the other invalid values I don't know, but try to give it proper values only and see what happens then. Regards, Pete
CaptnKebec Posted August 23, 2004 Author Report Posted August 23, 2004 Hi Pete, I resolved the problem. All I had to do is convert the decimal value to hex, do the increase or decrease, reconvert it to decimal and write to FSUIPC. That's weird, but it works! Thanks for the hints.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now