Go Down

Topic: Quick suggestion on approaching this problem (Read 2922 times) previous topic - next topic

dc42

Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

PaulS

Code: [Select]
  if (chqC<thres)
  {
    store=HIGH;
  }   

  else if (chqC>=thres)

If chgC is not less than thres, is there any possible way for it not to be greater than or equal to thres?

FullyJosh


Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.


I know the code is working when I test it in the serial monitor. However when I go to test it with the virtual keyboard most times a note is not being played. When it does play the note it is very quick and easily missed.




Code: [Select]
  if (chqC<thres)
  {
    store=HIGH;
  }   

  else if (chqC>=thres)

If chgC is not less than thres, is there any possible way for it not to be greater than or equal to thres?


You are correct, any time chqC is not less than thres, it is automatically assumed that it will be greater than or equal to the thres. I have that line so that the store value can get overwritten.

PaulS

Quote
I have that line so that the store value can get overwritten.

You need the else statement so that the store value can get overwritten, not the else if statement.

FullyJosh


You need the else statement so that the store value can get overwritten, not the else if statement.


Code: [Select]
else  {
       store=LOW;
         }


Something like that? Just tried running the code again and I'm having any luck.

PaulS

Quote
Just tried running the code again and I'm having any luck.

Luck has nothing do with writing code that works. Debugging does. I don't see any Serial.print() statements in your code that tell you what is happening.

FullyJosh

I left them out because I was scared that they would interfere with the AAC keys readings.
I wrote a separate code to test the laser and make sure it is working and I was using the right values.

dc42



Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.


I know the code is working when I test it in the serial monitor. However when I go to test it with the virtual keyboard most times a note is not being played. When it does play the note it is very quick and easily missed.


What exactly is the "virtual keyboard", and how have you connected it?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

FullyJosh

#23
Jan 01, 2013, 09:32 pm Last Edit: Jan 01, 2013, 09:34 pm by FullyJosh Reason: 1



Please explain what you mean by "pressing the key too fast" and "doesn't press the note". If you have added code to play tones, post the code as you now have it.


I know the code is working when I test it in the serial monitor. However when I go to test it with the virtual keyboard most times a note is not being played. When it does play the note it is very quick and easily missed.


What exactly is the "virtual keyboard", and how have you connected it?


http://www.youtube.com/watch?v=Svkh31xh5VI&feature=youtu.be I recorded a quick video to demonstrate the behaviour. Note that I decided to use an L.E.D. now because I thought it may have been some power issues with the actual laser but it appears it doesn't make a difference they are both behaving in the same way.

I am using a program called Mixcraft. I turned on the virtual keyboad in the program which allows me to use my computer keyboard. I don't think it's the virtual keyboard software's problem. I know this only because I also tried opening a word document and noticed that most times "a" doesn't appear, or it appears very delayed and some are dead on.

FullyJosh

Anyone else have an idea on why the code would work in the serial monitor but not with aac keys enabled?

dc42

What data does Mixcraft expect? How is it supposed to know how long a note is?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

FullyJosh


What data does Mixcraft expect? How is it supposed to know how long a note is?


Mixcraft will turn my computer keyboard into an actual musical keyboard. When I press the "a" key it plays the note and it will hold the note until I release my finger.

dc42

That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

FullyJosh


That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.


Problem with that is that the Leonardo doesn't have enough analog pins.

Do you know how I can fix the issue where your code works flawlessly in the serial monitor but starts glitching when I turn on aac keys?

dc42

#29
Jan 05, 2013, 12:04 am Last Edit: Jan 05, 2013, 12:07 am by dc42 Reason: 1


That's the problem then. There is no way that a serial port sending ASCII codes can convey information about how long a key was pressed. I think a Leonardo could do it, because I believe it can emulate a USB PC keyboard, for which the up- and down-codes are sent separately.


Problem with that is that the Leonardo doesn't have enough analog pins.

Do you know how I can fix the issue where your code works flawlessly in the serial monitor but starts glitching when I turn on aac keys?


Not without using a Leonardo or other device that can emulate a keyboard that returns scan codes. How many analog inputs do you need, and why? The Leonardo has 12, and you can add more using an external ADC or analog multiplexer.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Go Up