well let me ask some questions.
1) how old is the battery? it may need to be replaced if it is old and won't hold charge.
2) has the wiring been messed with? I ask because you may be loosing charge either through bad connections, or faulty wiring.
3) when was the last time you cleaned the carb and checked the floats to make sure they aren't bad?
4) is the knocking a constant sound, or does it vary with RPM?
2007 outlaw 525 IRS (now a 540)
Built by Poaris on 11/06
Motor by Duncan Racing 1/08
1987 Lt500R QUADZILLA (sold)
2007 outlander MAX 400 (bought new 4/09)